Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xsleonard/pystmark
Postmark library for python 2 and 3. Built on top of the requests library.
https://github.com/xsleonard/pystmark
email postmark postmarkapp python
Last synced: 3 months ago
JSON representation
Postmark library for python 2 and 3. Built on top of the requests library.
- Host: GitHub
- URL: https://github.com/xsleonard/pystmark
- Owner: xsleonard
- License: mit
- Created: 2013-01-21T00:45:15.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-06-15T16:57:25.000Z (over 1 year ago)
- Last Synced: 2024-10-03T10:44:59.448Z (4 months ago)
- Topics: email, postmark, postmarkapp, python
- Language: Python
- Homepage:
- Size: 730 KB
- Stars: 24
- Watchers: 4
- Forks: 15
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS.md
Awesome Lists containing this project
README
# pystmark
[![PyPI version](https://badge.fury.io/py/pystmark.png)](http://badge.fury.io/py/pystmark)
[![Build Status](https://travis-ci.org/xsleonard/pystmark.png)](https://travis-ci.org/xsleonard/pystmark)
[![Coverage Status](https://coveralls.io/repos/xsleonard/pystmark/badge.png)](https://coveralls.io/r/xsleonard/pystmark)[Postmark API](http://developer.postmarkapp.com/) library for python 2.7, 3.6 and pypy.
Built on top of the [requests](http://docs.python-requests.org/en/latest/) library.## Web Framework Integration
* [Flask-Pystmark](https://github.com/xsleonard/flask-pystmark)
## Documentation
The full Sphinx-compiled documentation is available here: [https://readthedocs.org/docs/pystmark/en/latest/](https://readthedocs.org/docs/pystmark/en/latest/)
## Example Usage
```python
from pystmark import (
Message,
send,
send_with_template,
send_batch,
send_batch_with_templates,
UnauthorizedError
)API_KEY = 'my_api_key'
SENDER = '[email protected]'# Send a single message
message = Message(
sender=SENDER,
to='[email protected]',
subject='Hi',
text='A message',
tag='greeting'
)response = send(message, api_key=API_KEY)
# Send a template message
model = {
'user_name': 'John Smith',
'company': {
'name': 'ACME'
}message = Message(
sender=SENDER,
to='[email protected]',
template_id=11111,
template_model=model,
tag='welcome',
)response = send_with_template(message, api_key=API_KEY)
# Send multiple messages
messages = [
Message(
sender=SENDER,
to='[email protected]',
subject='Hi',
text='A message',
tag='greeting',
message_stream='broadcasts',
)
]response = send_batch(messages, api_key=API_KEY)
# Send multiple messages with templates
messages = [
Message(
sender=SENDER,
to='[email protected]',
template_id=11111,
template_model=model,
tag='greeting',
message_stream='broadcasts',
)
]response = send_batch_with_templates(messages, api_key=API_KEY)
# Check API response error
try:
response.raise_for_status()
except UnauthorizedError:
print 'Use your real API key'# Check for errors in each message when sending batch emails:
for m in response.messages:
if m.error_code > 0:
print m.message
```## Contribution
1. Fork this repo
2. Make your changes and write a test for them
3. Add yourself to the [AUTHORS.md](./AUTHORS.md) file and submit a pull requestPlease run the tests with `./setup.py test --with-integration`, with at least python2.7,
before you make a pull request. Requirements for running the tests are in `tests/requirements.txt`.
The other versions will be handled by [travis-ci](https://travis-ci.org/).The pep8 tests may fail if using pypy due to [this bug](https://bugs.pypy.org/issue1207),
so that test is disabled if pypy is detected.## Copyright and License
pystmark is licensed under the MIT license. See the [LICENSE](./LICENSE) file for full details.