Git Product home page Git Product logo

python-postmark's Introduction

python-postmark library for Postmark

Supports Python 2.6 and greater, including 3.x.

Includes:

  • PMMail
  • PMBatchMail
  • PMBounceManager
  • Django email backend (postmark.django_backend.EmailBackend)

Contributors

See CONTRIBUTORS.md.

Changelog

Version 0.4.3

  • Added message_id property to messages for post-send record-tracking (jdavisp3)

Version 0.4.2

Version 0.4.1

  • Merged proper handling of content_subtype in the Django backend - thanks Josh Owen!

Version 0.4.0

  • Merged in Python 3 support - thanks Jacob!
  • Moving minimum python version to 2.6. If you need 2.4 support, please continue to use v0.3.2!

See full changelog

Usage

Make sure you have a Postmark account. Visit http://postmarkapp.com to sign up for an account. Requires a Postmark API key.

Import postmark.PMMail to use Postmark. Check class documentation on PMMail object for more information.

Django

The library can be used stand-alone with Django. You can also add the settings:

POSTMARK_API_KEY     = 'your-key'
POSTMARK_SENDER      = '[email protected]'
POSTMARK_TEST_MODE   = [True/False]
POSTMARK_TRACK_OPENS = [True/False]

to your settings.py file, and when you create a new PMMail object, it will grab the API key and sender automatically. Make sure the sender email address is one of your Sender Signature email addresses in Postmark. You can also customize the name on the sender by changing the format from '[email protected]' to 'Sender Name [email protected]' as long as the email part is part of a Sender Signature in Postmark.

Using POSTMARK_TEST_MODE=True will not actually send the email, but instead dump the JSON packet that would be sent to Postmarkapp.com. By default this setting is False, and if not specified, will be assumed to be False.

To reoute all Django E-Mail functions like send_mail() and mail_admins() through postmark use the following setting:

EMAIL_BACKEND = 'postmark.django_backend.EmailBackend'

But keep in mind that even when using standard Django functions the sender must be registered with postmarkapp.com.

Exceptions

class PMMailMissingValueException(Exception):
    #One of the required values for attempting a send request is missing

class PMMailSendException(Exception):
    #Base Postmark send exception

class PMMailUnauthorizedException(PMMailSendException):
    #401: Unathorized sending due to bad API key

class PMMailUnprocessableEntityException(PMMailSendException):
    # 422: Unprocessable Entity - usually an exception with either the sender not having a matching Sender Signature in Postmark.  Read the message details for further information

class PMMailServerErrorException(PMMailSendException):
    #500: Internal error - this is on the Postmark server side.  Errors are logged and recorded at Postmark.

class PMMailURLException(PMMailSendException):
    #A URLError was caught - usually has to do with connectivity and the ability to reach the server.  The inner_exception will have the base URLError object.

TODO

  • Add automatic multipart emails via regex stripping of HTML tags from html_body if the .multipart property is set to True
  • Refactor PMBounceManager Object and improve error handling within it.
  • Add PMBounceManager example to the Django test.
  • Write tests for large percentage of coverage
  • Fill out the "Usage" section

python-postmark's People

Contributors

themartorana avatar mattrobenolt avatar frozenskys avatar oraclebill avatar joshourisman avatar richleland avatar danxshap avatar joshowen avatar thruflo avatar jcbsv avatar benhodgson avatar jdavisp3 avatar maraujop avatar cyberdelia avatar vcainelli avatar brimcfadden avatar deegrayve avatar maximebf avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.