Skip to content
Postmark library for python 2 and 3. Built on top of the requests library.
Python
Branch: master
Clone or download

Latest commit

Latest commit e41d080 Sep 26, 2019

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
tests
.coveragerc
.gitignore
.gitmodule
.readthedocs.yml
.travis.yml
AUTHORS.md
LICENSE
MANIFEST.in
README.md
_pystmark_meta.py
pystmark.py
requirements.txt
setup.py

README.md

pystmark

PyPI version Build Status Coverage Status

Postmark API library for python 2.7, 3.6 and pypy. Built on top of the requests library.

Web Framework Integration

Documentation

The full Sphinx-compiled documentation is available here: https://readthedocs.org/docs/pystmark/en/latest/

Example Usage

import pystmark

API_KEY = 'my_api_key'
SENDER = 'me@example.com'

# Send a single message
message = pystmark.Message(sender=SENDER, to='you@example.com', subject='Hi',
                           text='A message', tag='greeting')
pystmark.send(message, api_key=API_KEY)

# Send a template message
 t_model = {'product_name': "Awesome Product",
            'name': "Customer Name",
            'action_url': "http://www.example.com/confirmation/aj3s5dopf98sdf",
            'sender_name': "Product Team",
            'product_address_line1': "Dover",
            'product_address_line2': "DE 19012"}

 message = pystmark.Message(sender=SENDER, to='you@example.com',
                            template_id=11111,
                            template_model=t_model,
                            tag='welcome')

 pystmark.send_with_template(message, api_key=API_KEY)

# Send multiple messages (via Postmark's batch send API)
recipients = ['you{0}@example.com'.format(i) for i in xrange(20)]
messages = [pystmark.Message(sender=SENDER, to=to, subject='Hi',
                             text='A message', tag='greeting')
            for to in recipients]

response = pystmark.send_batch(messages, api_key=API_KEY)

# Check API response error
try:
    response.raise_for_status()
except pystmark.UnauthorizedError:
    print 'Use your real API key'

Contribution

  1. Fork this repo
  2. Make your changes and write a test for them
  3. Add yourself to the 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.

The pep8 tests may fail if using pypy due to this bug, so that test is disabled if pypy is detected.

Copyright and License

pystmark is licensed under the MIT license. See the LICENSE file for full details.

You can’t perform that action at this time.