Commit Graph

280 Commits

Author SHA1 Message Date
Ansel Santosa
73a73ea01f Mailgun: Support stored templates
Add support for Mailgun's new template option

Fixes #155
2019-07-30 10:50:42 -07:00
medmunds
df3d577b41 Release 6.1 2019-07-07 16:20:22 -07:00
medmunds
181d5886eb Add MAILGUN_WEBHOOK_SIGNING_KEY setting.
Fixes #153.
2019-07-07 13:43:08 -07:00
medmunds
fe6ee5bf84 Release 6.0.1 2019-05-19 11:30:28 -07:00
medmunds
5dce0895f1 Fix UnicodeEncodeError error while reporting invalid email address.
Fixes #148.
2019-05-19 11:19:21 -07:00
medmunds
ebb6b041e7 Support using AnymailMessage with django-mailer
Make UNSET preserve its identity across pickling. (Also make its repr
mention "unset", to simplify interpretting stack traces.)

Fixes #147.
2019-05-08 13:16:01 -07:00
medmunds
4c443f5515 Release 6.0 2019-02-23 16:28:15 -08:00
medmunds
dabbdad3bd Properly encode path components used to construct API URLs
Resolves #144 and similar potential issues
2019-02-23 15:27:41 -08:00
medmunds
578bad9a57 SendGrid: generate unique message_id for each batch recipient
Closes #139
2019-02-23 15:01:54 -08:00
medmunds
d2d568b6d3 SendGrid: simplify personalizations processing; stop using "sections"
* Rework and simplify personalizations code (that had grown convoluted
  through several feature additions).

* Stop putting merge_global_data in legacy template "sections"; instead
  just merge it into individual personalization substitutions like we
  do for dynamic templates. (The "sections" version didn't add any
  functionality, had the potential for conflicts with the user's own
  template section tags, and was needlessly complex.)
2019-02-23 14:07:01 -08:00
Mike Edmunds
75d7671056 Add merge_metadata for other ESPs
Support merge_metadata in Mailgun, Mailjet, Mandrill, Postmark, 
SparkPost, and Test backends. (SendGrid covered in earlier PR.)

Also:
* Add `merge_metadata` to AnymailMessage, AnymailMessageMixin
* Add `is_batch()` logic to BasePayload, for consistent handling
* Docs

Note: Mailjet implementation switches *all* batch sending from their 
"Recipients" field to to the "Messages" array bulk sending option.
This allows an independent payload for each batch recipient.
In addition to supporting merge_metadata, this also removes the
prior limitation on mixing Cc/Bcc with merge_data.

Closes #141.
2019-02-23 13:32:28 -08:00
Janne Thoft
85dce5fd6a SendGrid: add merge_metadata
Add support in SendGrid backend for per-recipient metadata.
2019-02-21 12:44:53 -08:00
medmunds
412a1b78c6 Mailgun: Better error message for invalid sender domains
Try to catch cases where Mailgun will return HTTP 200-OK with the
text "Mailgun Magnificent API" rather than sending the email.

See #144.
2019-02-19 17:42:06 -08:00
medmunds
acd3ca00c8 Improve ESP response formatting in error messages 2019-02-19 17:22:01 -08:00
medmunds
f64e98141a Postmark: don't error on Cc/Bcc-only send; preserve recipient caps
Postmark docs notwithstanding, Postmark allows sending mail without a
To field, as long as there is some recipient in Cc or Bcc. The API
response has a slightly different shape in this case, and Anymail now
handles that.

Also updates related recipient status parsing. Previously, Anymail's
Postmark backend converted all recipient emails to lowercase for status
reporting, and omitted Cc or Bcc recipients from
`message.anymail_status.recipients[email]`. Now, the backend preserves
the case of each recipient email as originally sent, and includes Cc
and Bcc status.

Because client code may have been relying on lowercasing recipient
emails to check status, this is a potentially breaking change.

Fixes #135
2019-02-05 11:08:26 -08:00
medmunds
c5c015e9a1 Internal: add CaseInsensitiveCasePreservingDict
Like CaseInsensitiveDict (which we borrow from Requests), but preserves
case of the first key set rather than the last.
2019-02-05 11:01:55 -08:00
medmunds
4ee4b335a2 Release 5.0 2018-11-07 09:46:48 -08:00
medmunds
10f6f3f821 Postmark: Support both TemplateAlias and TemplateId as template_id
Accept either Postmark's template alias or numeric id for `template_id`.
2018-11-06 18:39:49 -08:00
medmunds
1d252ca412 Mailgun: better errors for misconfigured webhooks
Detect cases where inbound or tracking webhook url has been configured
in wrong Mailgun webhook.

See #129.
2018-11-06 18:10:59 -08:00
Leo Antunes
bb257152be Mailgun: treat temporary failure as deferred in tracking webhook
Map Mailgun severity: temporary failure event to Anymail "deferred" event, to distinguish it from severity: permanent failures which will show up as Anymail "bounced".

Also remap Mailgun reason: generic failure to Anymail "other" reject reason (rather than "bounced").

Closes #130
2018-11-01 15:26:49 -04:00
medmunds
56c11ce387 Release 4.3 2018-10-11 17:28:44 -07:00
medmunds
2cf14c3653 Mailgun: raise unsupported feature error on attachment without filename.
Mailgun's API silently drops attachments without filenames (and inline
attachments without Content-IDs). Raise an AnymailUnsupportedFeature
error on attempts to send these attachments.

Fixes #128
2018-10-11 15:38:50 -07:00
Leo Antunes
64f7d31d14 also consider Content-ID when marking attachment as inline (#126)
Handle MIME attachments with Content-ID as inline by default.

Treat MIME attachments that have a *Content-ID* but no explicit *Content-Disposition*
header as inline, matching the behavior of many email clients.
2018-10-11 14:29:00 -07:00
medmunds
4028eda583 Fix Python 3.4
(%-interpolation for bytes isn't available until Python 3.5)
2018-10-10 16:50:07 -07:00
medmunds
3f63fdd713 Mailgun: Fix lost attachments with non-ASCII filenames.
Workaround requests/requests#4652 (urllib3/urllib3#303), where
uploaded files in multipart/form-data are improperly given RFC 2231
encoded filenames. That format is not accepted by Mailgun's API (and is
prohibited by RFC 7578), resulting in the attachments being silently
dropped.

Fix is to patch up the multipart/form-data before posting to remove
the RFC 2231 encoding.

Fixes #125
2018-10-10 15:02:13 -07:00
medmunds
ddafac9fbd Add DEBUG_API_REQUESTS Anymail setting to dump API communications.
Optionally dump API requests and responses to stdout, to simplify
debugging of the raw API communications. Currently implemented only
for Requests-based backends.

This (undocumented) setting can log things like API keys, so is not
appropriate for use in production.
2018-10-10 14:24:35 -07:00
medmunds
0794617750 Release 4.2 2018-09-07 11:05:20 -07:00
medmunds
9c493dba72 Postmark: Support merge_data and batch sending.
Use Postmark /email/batch or /email/batchWithTemplates APIs when
merge_data provided.

Parse Postmark batch-send API responses, and improve accuracy of
parsing individual recipient status from all responses.

Closes #122
2018-09-06 17:24:04 -07:00
medmunds
753c895301 Postmark: Fix Postmark error on empty subject/body with template_id.
Postmark issues an error if Django's default empty strings are used
with template sends.

Include template send in Postmark integration tests. (Requires real
Postmark API token -- templates aren't testable with Postmark's
sandbox token.)

Fixes #121
2018-09-05 12:41:33 -07:00
medmunds
8b7b833a2b Release 4.1 2018-08-27 11:48:39 -07:00
medmunds
cb521e0e0e Python 3.8 (prep): Import Mapping etc. from collections.abc
Python 3.3 moved various collections abstract base classes from
`collections` to `collections.abc`, but also kept them available in
`collections` for compatibility with Python 2. Python 3.8 will allow
importing only from `collections.abc`.

(`collections.abc` hasn't yet been added to six.moves; see
https://github.com/benjaminp/six/issues/155.)
2018-08-27 11:24:44 -07:00
medmunds
382ebf249c SendGrid: Improve esp_extra["personalizations"] handling.
Allow merging `esp_extra["personalizations"]` dict into other
message-derived personalizations.

(See comments in #120)
2018-08-27 11:10:48 -07:00
medmunds
dbca13243f SendGrid: support new "dynamic" transactional templates
Closes #120
2018-08-24 18:21:42 -07:00
medmunds
e44978daf7 Release 4.0 2018-08-19 11:53:16 -07:00
medmunds
5212848dc3 Amazon SES: Work around SES bug that corrupts non-ASCII message bodies.
If you are using an SES ConfigurationSet with open or click tracking
enabled, SES replaces non-ASCII characters with question marks as it
rewrites the message to add tracking, if the bodies are sent with
`Content-Transfer-Encoding: 8bit` (which is Django's default for utf8
body parts).

Force potentially problematic parts to use CTE: quoted-printable
as a workaround.

Fixes #115.
2018-08-14 17:24:49 -07:00
medmunds
9e7814ad65 Mailgun: Support new (non-legacy) webhooks
Extend existing Mailgun tracking webhook handler to support both
original (legacy) and new (June, 2018) Mailgun webhooks.

Closes #117
2018-08-14 11:53:30 -07:00
medmunds
46ff2e859c Postmark: Add metadata support
Closes #114
2018-08-11 16:00:58 -07:00
medmunds
e6431a62f0 Change attach_inline_image default domain from hostname to "inline".
This avoids problems with ESPs that don't distinguish *Content-ID*
from attachment filename, where a local hostname ending in ".com" could
cause Gmail to block messages sent with inline attachments.
(Mailgun, Mailjet, Mandrill and SparkPost have APIs affected by this.)

Fixes #112.
2018-07-06 16:30:27 -07:00
medmunds
02e6daf9d4 SendGrid: drop deprecated sendgrid_v2 EmailBackend 2018-05-30 16:02:21 -07:00
medmunds
52a6d2d822 Tests: stop using sendgrid_v2 backend for settings tests 2018-05-30 16:00:49 -07:00
medmunds
23f44dce2d Begin v4.x changes 2018-05-30 15:19:20 -07:00
medmunds
f871dffbdb Release 3.0 2018-05-30 14:15:21 -07:00
Josh Kersey
d8d1407c61 SendGrid: change message_id from Message-ID/smtp-id to UUID anymail_id
SendGrid does not always correctly provide the sent Message-ID header value 
to a tracking webhook's smtp-id field, making it unreliable to use for Anymail's 
`message_id`.

Instead, generate a UUID `message_id` for Anymail tracking, and pass it from 
send to webhooks in SendGrid custom args as anymail_id.

Webhooks will fall back to smtp-id for compatibility with previously-sent 
messages that didn't have an anymail_id custom arg.

Fixes #108
2018-05-30 11:52:36 -07:00
medmunds
3cadaca9dd Mailjet: handle bare event when webhook "group events" not enabled
Fixes #106
2018-05-15 10:50:05 -07:00
medmunds
59a90c6895 Release 2.2 2018-04-16 15:57:10 -07:00
medmunds
dd26fd3108 Don't require boto3 if Amazon SES webhooks aren't actually used
Delay raising AnymailImproperlyInstalled from webhooks.amazon_ses
until an SES webhook view is instantiated. Allows anymail.urls
to import webhooks.amazon_ses without error.

Fixes #103
2018-04-16 15:41:00 -07:00
medmunds
d9ea741cba Release 2.1 2018-04-11 12:33:13 -07:00
medmunds
5598c87e62 Backends: identify source of problem in AnymailInvalidAddress message
Include the name of the field with the the unparsable email address
in AnymailInvalidAddress error messages.

Should help tracking down problems like in #98.
2018-04-11 11:50:06 -07:00
medmunds
f0d744a796 Internal: remove unused, undocumented AnymailInboundEvent attrs
AnymailInternalEvent had some properties that were actually implemented
in AnymailInboundMessage. The event versions were never documented,
and never contained useful data (they were always set to None).
2018-04-11 10:52:48 -07:00
Mike Edmunds
ef69fa3bf7 Amazon SES support
Integrate Amazon SES.

Closes #54.
2018-04-11 10:35:23 -07:00