Commit Graph

68 Commits

Author SHA1 Message Date
medmunds
fe1e2d1ae5 Refactor backend
* Break apart massive _send call
* Try to facilitate subclassing
* Centralize fail_silently handling during _send
* Include original EmailMessage as exception attr
2015-12-02 12:41:26 -08:00
medmunds
b8cdc6ce82 Cleanup Djrill exceptions
* Add common base DjrillException

* Simplify backend by moving logic
  to describe errors into base DjrillException

* Add NotSerializableForMandrillError
  for JSON serialization errors
2015-12-02 10:52:20 -08:00
medmunds
d14b87c910 Raise error for invalid/rejected recipients
Raise new MandrillRecipientsRefused exception
when Mandrill returns 'reject' or 'invalid' status
for *all* recipients of a message.

(Similar to Django's SMTP email backend raising
SMTPRecipientsRefused.)

Add setting MANDRILL_IGNORE_RECIPIENT_STATUS
to override the new exception.

Trap JSON parsing errors in Mandrill API response,
and raise MandrillAPIError for them. (Helps with #93.)

Closes #80.
Closes #81.
2015-12-01 13:26:21 -08:00
medmunds
8433e6d660 Clean up all imports
* Use relative imports within djrill package
* Standardize ordering
* Remove absolute_import (it's standard in all
  python versions we now support)
2015-11-30 17:33:08 -08:00
medmunds
632334b426 Don't access MANDRILL_API_URL setting at module level
Move MANDRILL_API_URL setting lookup into Djrill
backend init (where it's used).

Because "modules should not in general use settings
stored in django.conf.settings at the top level".
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#use-of-django-conf-settings
2015-11-30 17:20:27 -08:00
medmunds
3a6e0ebb30 Clean up session sharing
* Test cases
* Fix premature session.close when caller
  is managing email backend connection
* Ensure session closed correct in exceptions
* Changelog

(Also fixes bug where JSON serialization errors
didn't respect fail_silently.)
2015-11-30 16:50:58 -08:00
medmunds
942a6df8c3 Drop unintended json date encoding 2015-11-29 14:42:12 -08:00
medmunds
699216ba00 Drop legacy DjrillBackendHTTPError exception 2015-11-29 12:55:16 -08:00
medmunds
f7bd9f3a25 Add Djrill version to User-Agent header
(Makes version show up in Mandrill API logs)
2015-09-25 18:23:45 -07:00
William Hector
7179734a08 Allow global_merge_vars to be merged in with the per message dict, with keys in the latter taking precedent.
Update the docs accordingly.
2015-07-14 05:57:12 +01:00
William Hector
883b23362c Allow Mandrill specific options to be set globally in the settings file.
This is useful to set options such as tracking_domain etc per instance when using subaccounts with Mandrill.
2015-07-12 01:19:59 +01:00
William Hector
bac85511b5 Use requests.session to pool requests when mass sending mail
Tests modified to patch the ression post and close session upon error.
RE: http://stackoverflow.com/q/30982717/647002
2015-07-11 22:12:14 +01:00
medmunds
00ddd2f4f6 Improve MandrillAPIError.__str__
* Include formatted response from Mandrill API (if any)
* Clean up recipient address(es)
2015-05-13 15:43:54 -07:00
medmunds
fd75c4b24d Deprecate DjrillBackendHTTPError 2015-05-12 18:27:29 -07:00
medmunds
cc56b96efa Improve and document JSON serialization for Mandrill API
* Add some context to exceptions on unserializable
  values (addresses #89).
* Document need to format merge data
  (into something JSON-serializable).
* Add RemovedInDjrill2 DeprecationWarning.
* Deprecate blanket date/datetime serialization.
2015-05-12 13:29:52 -07:00
medmunds
bbc2e06091 Support Django 1.8 reply_to param. 2015-02-25 16:30:02 -08:00
medmunds
76e29c0845 Support merge_language option.
Closes #84.
2015-01-16 13:48:39 -08:00
Patrick Kimber
0063fde2e5 if missing 'from_email', then 'log_message' will fail to build 2014-08-04 15:32:24 +01:00
medmunds
780d4f98f7 use_template_subject and use_template_from
Change "clear_subject" and "clear_from" to clarify expected usage.
Update docs.
Acknowledge contribution.
2014-05-28 21:09:28 -07:00
medmunds
78ff0af229 Merge branch 'feature/use-mandrill-template-defaults' of git://github.com/nikolay-saskovets/Djrill into nikolay-saskovets-feature/use-mandrill-template-defaults 2014-05-28 20:42:36 -07:00
nikolay.saskovets
0e27a62f3c prepare for PR to mainstream (tests, docs, ...) 2014-05-16 07:37:51 -04:00
nikolay.saskovets
c3420d156e ability to use default Mandrill subject and from fields 2014-05-16 06:57:58 -04:00
winhamwr
70dc022f77 Handle unicode attachment content in both python 2.X and python3. 2014-04-23 16:59:48 -04:00
Michael Hobbs
21e8727b1d use MANDRILL_SUBACCOUNT to match the API field 2014-04-11 14:24:31 -07:00
Sameer Al-Sakran
cd8c2b8760 add subaccount support to djrill 2014-04-11 13:15:09 -07:00
medmunds
d7c06bb576 Better handling for cc and bcc recipients.
Fixes #59.
2014-01-25 12:35:23 -08:00
medmunds
1e44392b13 Allow all extra message headers in send.
Mandrill has relaxed previous API restrictions on headers.
Fixes #58.
2014-01-25 11:58:12 -08:00
Eric Hennings
e1c78ec197 Add the Mandrill send API response to EmailMessage as a property, mandrill_response, when a message is sent. For errors, set mandrill_response to None. Add tests & docs. 2013-12-22 14:12:57 -08:00
medmunds
12426204a5 Support important, view_content_link, return_path_domain, subaccount.
Closes #49.
2013-10-19 13:24:56 -07:00
medmunds
b26ba42e77 Support async, ip_pool, and send_at.
Closes #40.
Closes #48.
2013-10-19 13:09:05 -07:00
medmunds
f565a4c294 Mandrill requires template_content field for send-template.
Fixes #47.
2013-10-19 11:41:20 -07:00
crccheck
393d6e7fa8 Fix: html messages were sent as text
If you followed the instructions at:
<https://docs.djangoproject.com/en/1.5/topics/email/#sending-alternative-content-types>,
djrill would send the body as 'text' instead of 'html', resulting in
ugly emails.

This also fixes how `[auto_text]` could be set, but couldn't do anything.
If you wanted to use `auto_text=True`, you would have to send a null
body and then `attach_alternative` your real body. I didn't add a test
case for this because they're like... orthogonal..., and gets into
behavior testing vs unit testing.

  [auto_text]: https://djrill.readthedocs.org/en/master/usage/sending_mail/#auto_text
2013-09-26 15:32:55 -05:00
medmunds
717e048365 Add Mandrill send options auto_html, tracking_domain, signing_domain 2013-03-27 11:08:04 -07:00
medmunds
ab1de7be2a (Don't use python builtin 'vars' as a parameter name) 2013-03-27 11:08:04 -07:00
medmunds
64f32fbc72 Use python's json rather than Django's
django.utils.simplejson is deprecated; Python 2.6+ includes json.
Fixes #32.
2013-03-13 09:52:51 -07:00
medmunds
13c6125bda Support Mandrill inline_css sending option 2013-03-05 13:57:51 -08:00
medmunds
09de5faebe Support embedded images.
Treat image attachments with a Content-ID header as embedded, rather than ordinary attachments. (Rationale is that you must set the content-id to be able to refer to the image within your html, so that's a reasonable indicator to handle it as embedded.)
2013-03-01 13:58:07 -08:00
medmunds
92d413f5ae Don't filter attachment types
Mandrill dropped filtering on attachment mimetypes, so stop enforcing this in Djrill.
Fixes #26
2013-02-28 17:47:47 -08:00
medmunds
ed3249cede Correct name/content lists for template_content, merge_vars, global_merge_vars.
Fixes #24.
2013-01-13 08:16:40 -08:00
medmunds
ac0614a633 More Python 3.2 fixes - attachment encoding 2013-01-12 13:32:57 -08:00
medmunds
8de6b218b9 Handle bcc as Mandrill bcc_address, rather than additional to address 2013-01-12 10:26:42 -08:00
medmunds
8f9afdff7e Move MANDRILL_API_URL to package root (out of backend) 2013-01-11 17:34:17 -08:00
medmunds
ad4b9f38ff Raise NotSupportedByMandrillError for unsupported attachment mimetypes. 2013-01-11 17:26:09 -08:00
medmunds
18d27fdb21 Exception cleanup
Introduce djrill.NotSupportedByMandrillError for unsupported functionality (previously used generic ValueError).
Change to djrill.MandrillAPIError, derived from requests.HTTPError, for API error responses (previously used djrill.mail.backends.djrill.DjrillBackendHTTPError -- retained as equivalent for backwards compatibility).
2013-01-11 16:59:42 -08:00
medmunds
4be12952a3 Add send-template tests (and fixes).
Add test cases for send-template.
Expand template_content dict into Mandrill's name/value array.
Don't send template_content as "None" if missing.

Clean up some variable names in the backend.
2013-01-11 13:28:49 -08:00
medmunds
3b237a59db Merge branch 'send-template' of git://github.com/peillis/Djrill into send_template 2013-01-09 12:39:18 -08:00
medmunds
5b4f4c12cb Support sending attachments 2013-01-03 13:52:41 -08:00
peillis
046987a934 adding the send-template call 2012-12-24 13:36:37 +01:00
medmunds
8aab5e31b7 Expose most Mandrill send features on EmailMessage objects.
* Supports additional Mandrill send-API attributes on any ``EmailMessage``-derived object -- see details in readme
* Removes need for MANDRILL_API_URL in settings (since this is tightly tied to the code)
* Removes ``DjrillMessage`` from the readme (but not the code or tests) -- its functionality is now duplicated or exceeded by standard EmailMessage with additional attributes
* Ensures send(fail_silently=True) works as expected
2012-12-10 11:36:18 -08:00
Jared Morse
2eba028a1a DjrillBackend preserve_recipients 2012-12-03 18:55:05 -08:00