# 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 = 'me@example.com'
# Send a single message
message = Message(
sender=SENDER,
to='you@example.com',
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='you@example.com',
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='you@example.com',
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='you@example.com',
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 request
Please 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/xsleonard/pystmark",
"name": "pystmark",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "postmark postmarkapp email",
"author": "Steve Leonard",
"author_email": "sleonard76@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/0c/0b/49a1d54577062c41a20744f5c656dc6b91c0452d887220487fd3583c6ec9/pystmark-0.5.3.tar.gz",
"platform": "any",
"description": "# pystmark\n\n[![PyPI version](https://badge.fury.io/py/pystmark.png)](http://badge.fury.io/py/pystmark)\n[![Build Status](https://travis-ci.org/xsleonard/pystmark.png)](https://travis-ci.org/xsleonard/pystmark)\n[![Coverage Status](https://coveralls.io/repos/xsleonard/pystmark/badge.png)](https://coveralls.io/r/xsleonard/pystmark)\n\n\n[Postmark API](http://developer.postmarkapp.com/) library for python 2.7, 3.6 and pypy.\nBuilt on top of the [requests](http://docs.python-requests.org/en/latest/) library.\n\n## Web Framework Integration\n\n* [Flask-Pystmark](https://github.com/xsleonard/flask-pystmark)\n\n## Documentation\n\nThe full Sphinx-compiled documentation is available here: [https://readthedocs.org/docs/pystmark/en/latest/](https://readthedocs.org/docs/pystmark/en/latest/)\n\n## Example Usage\n\n```python\nfrom pystmark import (\n Message,\n send,\n send_with_template,\n send_batch,\n send_batch_with_templates,\n UnauthorizedError\n)\n\nAPI_KEY = 'my_api_key'\nSENDER = 'me@example.com'\n\n# Send a single message\nmessage = Message(\n sender=SENDER,\n to='you@example.com',\n subject='Hi',\n text='A message',\n tag='greeting'\n)\n\nresponse = send(message, api_key=API_KEY)\n\n# Send a template message\nmodel = {\n 'user_name': 'John Smith',\n 'company': {\n 'name': 'ACME'\n }\n\nmessage = Message(\n sender=SENDER,\n to='you@example.com',\n template_id=11111,\n template_model=model,\n tag='welcome',\n)\n\nresponse = send_with_template(message, api_key=API_KEY)\n\n# Send multiple messages\nmessages = [\n Message(\n sender=SENDER,\n to='you@example.com',\n subject='Hi',\n text='A message',\n tag='greeting',\n message_stream='broadcasts',\n )\n]\n\nresponse = send_batch(messages, api_key=API_KEY)\n\n# Send multiple messages with templates\nmessages = [\n Message(\n sender=SENDER,\n to='you@example.com',\n template_id=11111,\n template_model=model,\n tag='greeting',\n message_stream='broadcasts',\n )\n]\n\nresponse = send_batch_with_templates(messages, api_key=API_KEY)\n\n# Check API response error\ntry:\n response.raise_for_status()\nexcept UnauthorizedError:\n print 'Use your real API key'\n\n# Check for errors in each message when sending batch emails:\nfor m in response.messages:\n if m.error_code > 0:\n print m.message\n```\n\n## Contribution\n\n1. Fork this repo\n2. Make your changes and write a test for them\n3. Add yourself to the [AUTHORS.md](./AUTHORS.md) file and submit a pull request\n\nPlease run the tests with `./setup.py test --with-integration`, with at least python2.7,\nbefore you make a pull request. Requirements for running the tests are in `tests/requirements.txt`.\nThe other versions will be handled by [travis-ci](https://travis-ci.org/).\n\nThe pep8 tests may fail if using pypy due to [this bug](https://bugs.pypy.org/issue1207),\nso that test is disabled if pypy is detected.\n\n## Copyright and License\n\npystmark is licensed under the MIT license. See the [LICENSE](./LICENSE) file for full details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python library for the Postmark API (http://developer.postmarkapp.com/).",
"version": "0.5.3",
"project_urls": {
"Homepage": "https://github.com/xsleonard/pystmark"
},
"split_keywords": [
"postmark",
"postmarkapp",
"email"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0c0b49a1d54577062c41a20744f5c656dc6b91c0452d887220487fd3583c6ec9",
"md5": "fe42f426f8e4895b062d48c93d78a7b7",
"sha256": "4d73827f0b00dc03fade324ab682fb4af7039c53e7f648a453eafec836d12018"
},
"downloads": -1,
"filename": "pystmark-0.5.3.tar.gz",
"has_sig": false,
"md5_digest": "fe42f426f8e4895b062d48c93d78a7b7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23388,
"upload_time": "2023-06-15T16:59:44",
"upload_time_iso_8601": "2023-06-15T16:59:44.610916Z",
"url": "https://files.pythonhosted.org/packages/0c/0b/49a1d54577062c41a20744f5c656dc6b91c0452d887220487fd3583c6ec9/pystmark-0.5.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-15 16:59:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "xsleonard",
"github_project": "pystmark",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": [
[
">=",
"1.2.0"
]
]
}
],
"lcname": "pystmark"
}