skip to navigation
skip to content

Not Logged In

pyramid_postmark 0.2

Integrate the Postmark email service with a Pyramid web application.

Latest Version: 0.3.2

[pyramid_postmark][] is a package that integrates the [Postmark][] email sending
service with a [Pyramid][] web application. It's a very thin layer around the
[python-postmark][] library that provides:

* `request.mailer`, a configured `postmark.PMBatchMail` instance
* `request.send_email` a function to send one or more email messages

These are integrated by default with the [pyramid_tm][] transaction machinery, so
emails are only sent if the current request is successful.

# Install

Install using `pip` or `easy_install`, e.g.:

pip install pyramid_postmark

# Configure

Provide `postmark.api_key` in your application's `.ini` settings:

postmark.api_key = <your key="">

Include the package in the configuration portion of your Pyramid app:


# Use

You can then send an email like this:

# E.g.: in a view callable / anywhere where you're handling a `request`.
from postmark import PMMail
email = PMMail(sender='', to='', subject='Subject',


', text_body='Body')

Or send multiple emails:

request.send_email([email, email])

Or use the batch mailer directly:

request.mailer.messages = [email]

Note that your sender email will need to match your [Postmark sender signature][].

By default, `request.send_email` sends the email iff the current transaction
succeeds. You can override this using the `postmark.should_join_tx` flag in
your `.ini` settings:

postmark.should_join_tx = false

Or when calling `request.send_email`:

request.send_email(email, should_join_tx=False)

If you're feeling optimisic, you can send the email in the background:

request.send_email(email, in_background=True)

Note that background sending works whether you send immediately or wait for the
current transaction to succeed. i.e.: As and when the email is to be sent, it
is send in a background thread using the following code:

do_send = thread_cls(target=mailer.send).start if in_background else mailer.send

# Tests

Tested on python2.7 only (as [python-postmark][] is not yet Python3 compatible).
Install `mock`, `nose` and `coverage` then e.g.:

$ nosetests --with-coverage --with-doctest --cover-package pyramid_postmark pyramid_postmark
Name Stmts Miss Cover Missing
pyramid_postmark 5 0 100%
pyramid_postmark.hooks 22 0 100%
TOTAL 27 0 100%
Ran 3 tests in 0.017s


[Postmark sender signature]:
File Type Py Version Uploaded on Size
pyramid_postmark-0.2.tar.gz (md5) Source 2012-09-02 5KB
  • Downloads (All Versions):
  • 14 downloads in the last day
  • 51 downloads in the last week
  • 123 downloads in the last month