Commit Graph

861 Commits

Author SHA1 Message Date
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
medmunds
f89d92bc37 Tests: avoid pummeling httpbin.org
Tag RequestsBackendLiveTestCase as 'live' so it only runs in a couple
of Travis builds (rather than all 20+ of them).
2019-02-23 13:49:00 -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
a283def798 Travis: only need to avoid tox==3.7.0
tox 3.7.1 (or whatever's next) will fix the issue described in 976bca1.
2019-02-19 17:30:45 -08:00
medmunds
e91d95a41e Suggest including settings and code in GitHub issue template 2019-02-19 17:23:23 -08:00
medmunds
acd3ca00c8 Improve ESP response formatting in error messages 2019-02-19 17:22:01 -08:00
Mike Edmunds
978996d7b8 Test without optional packages
Tox:
* Add Tox factor for extras (all, none, individual ESP).
  For now, only break out ESPs that have specific extra
  dependencies (amazon_ses, sparkpost).
* Install most package dependencies (including extras)
  through the package itself.
* Use new runtests.py environment vars to limit test tags
  when Tox isn't installing all extras.

Travis:
* Rework matrix to request specific TOXENVs directly;
  drop tox-travis.

Test runner (runtests.py):
* Centralize RUN_LIVE_TESTS logic in runtests.py
* Add ANYMAIL_ONLY_TEST and ANYMAIL_SKIP_TESTS env vars
  (comma-separated lists of tags)

Test implementations:
* Tag all ESP-specific tests with ESP
* Tag live tests with "live"
* Don't import ESP-specific packages at test module level. 
  (Test discovery imports test modules before tag-based filtering.)

Closes #104
2019-02-09 15:04:08 -08:00
medmunds
653fdac3cc Tests: Add django22-pypy3 to tox environments
Fixes #140
2019-02-08 12:28:59 -08:00
medmunds
bd55d8c298 Rework editorconfig
* Most file types prefer 2-space indents, so now default
  to that and list the exceptions
* Add max_line_length=120 for .py files (Django convention)
* Bat files require CRLF
2019-02-08 12:05:57 -08:00
medmunds
8464d3a231 Docs: note SERVER_EMAIL setting default won't work with most ESPs
mail_admins, mail_managers, and similar Django error reporting
generally won't work with the default SERVER_EMAIL setting
root@localhost.
2019-02-08 11:37:15 -08:00
medmunds
7b58d87079 Docs: Show code cross-reference links as clickable (blue) 2019-02-05 11:34:51 -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
3013eaf24b Travis: Xenial pypy currently requires explicit versions
"At the moment" Travis Xenial environment can't resolve
`python=pypy` or `python=pypy3` unless you include the specific
pypy version number.

https://travis-ci.community/t/pypy-2-7-on-xenial/889/4
https://travis-ci.community/t/pypy-2-7-on-xenial/889/5
2019-01-17 11:27:40 -08:00
medmunds
f1fedfcfeb Travis: switch to Xenial build environment
(Allows testing Python 3.7 without using sudo.)
2019-01-17 11:15:44 -08:00
medmunds
a35ba9395d Tox/Travis: enable Django 2.2alpha testing 2019-01-17 11:14:01 -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
b59aadd50a Update changelog for recent commits 2018-11-06 18:38:07 -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
eca1f5c399 SparkPost: update backend tests with 1/2019 error format.
Update SparkPost backend tests to follow 1/2019 changes to Transmissions
API error reporting format. (No changes are required in the Anymail
backend.)

See #123
2018-10-11 16:47:10 -07:00
medmunds
d7ea9971f0 SparkPost: add test for generation_failure webhook event.
Async template rendering errors will result in "generation_failure"
webhook events. Anymail handled these, but didn't have a specific test
for them. Since they'll become more common when SparkPost switches all
template rendering to async in 1/2019, good to verify they work as
expected.

See #123
2018-10-11 16:41:17 -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
1ad406a9b5 Docs: fix typo in SendGrid 2018-09-06 17:16:16 -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
6b99b7ef4f Docs: update readme test rendering to new PyPI layout, styles 2018-08-19 16:17:07 -07:00
medmunds
be7cc10a35 Use pipenv (Pipfile) to maintain development environment 2018-08-19 12:36:42 -07:00
medmunds
e44978daf7 Release 4.0 2018-08-19 11:53:16 -07:00
medmunds
13ffd5db40 Docs: add Rate-the-Docs 2018-08-18 17:36:10 -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
b5f8e86dd4 Docs: update ESP features table with new Postmark metadata support 2018-08-14 16:22:31 -07:00
medmunds
cf42495ab1 Travis: move live tests to Django 2.1 2018-08-14 16:14:10 -07:00
medmunds
33f0f4b141 Tox: fix django111-pypy(2) and django20-py36 builds
(pypy2 is only invoked as pypy, at least in Travis env)
2018-08-14 16:14:10 -07:00
medmunds
16df17e5b8 Travis: test with released Python 3.7
The python3.7-dev environment available on Travis default trusty is
apparently an outdated beta. Released Python 3.7 is only available in
Travis on the xenial platform (and xenial is currently only available
with sudo=true).
2018-08-14 16:14:09 -07:00
medmunds
0520ee3d70 Tox: update Django 2.1 tests to allow released version only
(and don't allow failures on Django 2.1 tests)
2018-08-14 12:11:11 -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