Tornado helper

There is a mixin for Tornado support. You could implement request handler like this:

from postmarker.tornado import PostmarkMixin
from tornado.web import RequestHandler

class EmailHandler(PostmarkMixin, RequestHandler):

    def post(self):
        # Awesome stuff here
        # ...
        # Send single email
            Subject='Postmark test',
            HtmlBody='<html><body><strong>Hello</strong> dear Postmark user.</body></html>'
        # Send batch
                'From': '',
                'To': '',
                'Subject': 'Postmark test',
                'HtmlBody': '<html><body><strong>Hello</strong> dear Postmark user.</body></html>',
                'From': '',
                'To': '',
                'Subject': 'Postmark test 2',
                'HtmlBody': '<html><body><strong>Hello</strong> dear Postmark user.</body></html>',
        # Or do whatever you want to do with postmark
        bounces = self.postmark_client.bounces.all()

To make it work, define postmark_server_token option:

from tornado.web import Application

app = Application(
        (r'/send/', EmailHandler),

And run your app! That’s it. All possible options have the same name as in PostmarkClient prefixed with postmark_:

  • postmark_server_token

  • postmark_account_token

  • postmark_verbosity

  • postmark_max_retries

  • postmark_timeout