/postmark/__init__.py

https://github.com/digi604/python-postmark · Python · 105 lines · 102 code · 3 blank · 0 comment · 0 complexity · 55d94d6f6ea0b0058b56be33e1933aee MD5 · raw file

  1. __version__ = '0.2.0'
  2. __author__ = "Dave Martorana (http://davemartorana.com) & Richard Cooper (http://frozenskys.com)"
  3. __date__ = '2010-April-14'
  4. __url__ = 'http://postmarkapp.com'
  5. __copyright__ = "(C) 2009-2010 David Martorana, Wildbit LLC, Python Software Foundation."
  6. __contributors__ = "Dave Martorana (themartorana), Bill Jones (oraclebill), Richard Cooper (frozenskys)"
  7. __doc__ = '''
  8. PMMail object for Postmark (http://postmarkapp.com)
  9. Version: ''' + __version__ + '''
  10. Author: ''' + __author__ + '''
  11. Last Updated: ''' + __date__ + '''
  12. Contributors: ''' + __contributors__ + '''
  13. CHANGE LOG:
  14. Version 0.2.0
  15. - Merged with frozenskys/master to bring in PMBounceManager
  16. - Support for multiple to/cc (limit: 20 per)
  17. - Changed .recipient to .to (legacy support for .recipient left in)
  18. - Tag support (.tag) added
  19. - Fixed the email endpoint
  20. - Fixed a Django backend issue for multiple recipients (max 20)
  21. Version 0.1.6
  22. - Added support for Bounces API
  23. Version 0.1.5
  24. - Added ".cc" property for carbon copy recipients. Changed django_backend to
  25. support multiple recipients, and to use "to" rather than "recipients" on the django
  26. mail object to prevent accidental leakage of BCC recipients.
  27. Version 0.1.4
  28. - Added ".reply_to" property. The "ReplyTo" custom header is unallowed by Postmark
  29. now, and their documentation has been updated to reflect the change.
  30. http://developer.postmarkapp.com
  31. Version 0.1.3
  32. - Major fix to the way properties were being used, fixes doc strings in properties
  33. - "custom_headers" is now always a dict, even if set to None
  34. Version 0.1.2
  35. - Added 'custom_headers' property (must be a dictionary) to PMMail object
  36. - Added optional 'test' argument to send function to print JSON message instead of actually sending it
  37. Version 0.1.1:
  38. - Initial release
  39. USEAGE:
  40. Make sure you have a Postmark account. Visit
  41. http://postmarkapp.com to sign up for an account.
  42. Requires a Postmark API key.
  43. Import postmark.PMMail to use Postmark Sending.
  44. Check class documentation on PMMail object for
  45. more information.
  46. Import postmark.PMBounceManager to use Postmark Bounce API.
  47. Check class documentation on PMBounceManager object for
  48. more information.
  49. DJANGO:
  50. The library can be used stand-alone with Django. You can also
  51. add the setting
  52. POSTMARK_API_KEY = 'your-key'
  53. POSTMARK_SENDER = '<From Name> from@emailaddress.com'
  54. to your settings.py file, and when you create a new PMMail object,
  55. it will grab the API key automatically.
  56. EXCEPTIONS:
  57. PMMailMissingValueException(Exception):
  58. One of the required values for attempting a send request is missing
  59. PMMailSendException(Exception):
  60. Base Postmark send exception
  61. PMMailUnauthorizedException(PMMailSendException):
  62. 401: Unathorized sending due to bad API key
  63. PMMailUnprocessableEntityException(PMMailSendException):
  64. 422: Unprocessable Entity - usually an exception with either the sender
  65. not having a matching Sender Signature in Postmark. Read the message
  66. details for further information
  67. PMMailServerErrorException(PMMailSendException):
  68. 500: Internal error - this is on the Postmark server side. Errors are
  69. logged and recorded at Postmark.
  70. PMMailURLException(PMMailSendException):
  71. A URLError was caught - usually has to do with connectivity
  72. and the ability to reach the server. The inner_exception will
  73. have the base URLError object.
  74. TODO:
  75. Add automatic multipart emails via regex stripping of HTML tags from html_body
  76. if the .multipart property is set to True
  77. '''
  78. from core import *