Commit Graph

154 Commits

Author SHA1 Message Date
medmunds
2bf492c2f4 Docs: Update intersphinx source urls
Python and Django have both moved their docs to https.
2018-01-17 13:10:49 -08:00
medmunds
7e908184ed Postmark: support "clicked" tracking events
Handle Postmark's new click webhook.

Closes #78
2017-11-02 11:48:02 -07:00
medmunds
bb68f3dd6d Mailgun: fix event/metadata param extraction in tracking webhook
Mailgun merges user-variables (metadata) into the webhook post data
interspersed with the actual event params. This can lead to ambiguity
interpreting post data.

To extract metadata from an event, Anymail had been attempting to avoid
that ambiguity by instead using X-Mailgun-Variables fields found in the
event's message-headers param. But message-headers isn't included in
some tracking events (opened, clicked, unsubscribed), resulting in
empty metadata for those events. (#76)

Also, conflicting metadata keys could confuse Anymail's Mailgun event
parsing, leading to unexpected values in the normalized event. (#77)

This commit:
* Cleans up Anymail's tracking webhook to be explicit about which
  multi-value params it uses, avoiding conflicts with metadata keys.
  Fixes #77.
* Extracts metadata from post params for opened, clicked and
  unsubscribed events. All unknown event params are assumed to be
  metadata. Fixes #76.
* Documents a few metadata key names where it's impossible (or likely
  to be unreliable) for Anymail to extract metadata from the post data.

For reference, the order of params in the Mailgun's post data *appears*
to be (from live testing):
* For the timestamp, token and signature params, any user-variable with
  the same name appears *before* the corresponding event data.
* For all other params, any user-variable with the same name as a
  Mailgun event param appears *after* the Mailgun data.
2017-10-27 13:26:37 -07:00
medmunds
01f56ae2b0 Prep for 1.0 release
* Remove "pre-1.0" warnings in docs, readme
* Jump trove classifer from pre-alpha all the way up to stable
  (arguably this should have been "beta" for the past several months)
2017-09-08 17:16:18 -07:00
medmunds
9c3761c216 Docs: add info on batch send performance 2017-09-08 15:46:28 -07:00
medmunds
0a95f1346a Docs: add info on handling transient ESP errors
Closes #55
2017-09-08 14:27:49 -07:00
medmunds
b6c75fe06b Docs: update intersphinx refs from Python 3.5 to 3.6 2017-09-08 14:19:43 -07:00
medmunds
90b9dc6cfa Docs: simplify PyPI links
Use `:pypi:` sphinx-ext-extlink role for links to PyPI,
and add some missing package links.
2017-09-08 14:16:09 -07:00
medmunds
2faa5f96cb Clean up and document Anymail's test EmailBackend
* Change Anymail's test EmailBackend to collect sent messages in
  django.core.mail.outbox, same as Django's own locmem EmailBackend.
  (So Django's test runner will automatically clear accumulated mail
  between test cases.)

* Rename EmailMessage `test_response` attr to `anymail_test_response`
  to avoid conflicts, and record merged ESP send params in
  new `anymail_send_params` attr.

* Add docs

Closes #36.
2017-09-01 13:13:25 -07:00
Jonas Haag
a9c663f36a Docs: Add more mail template apps (#72) 2017-08-29 12:07:34 -07:00
medmunds
3809d3d2e2 Mailjet: correct settings docs
`MAILJET_SECRET_KEY` not `MAILJET_API_SECRET`.
(Heading was correct; text and example were wrong.)

Fixes #71
2017-07-24 11:13:59 -07:00
medmunds
516312bf00 Docs: note auth header must be passed through WSGI for webhooks
(See #69.)
2017-07-13 16:05:54 -07:00
medmunds
54d2fe2513 Mailjet: add docs 2017-07-13 15:43:11 -07:00
medmunds
fc59707133 Webhooks: default tracking event tags=[], metadata={}
If a tracking event doesn't contain tags or metadata, set the event
record fields to tags=[] or metadata={} to simplify checking values.

Closes #67
2017-06-30 16:56:36 -07:00
medmunds
0b50f278b5 Docs: add contact email for security issues 2017-05-22 11:46:37 -07:00
medmunds
8bdc67939a Flake8 clean 2017-04-16 11:43:13 -07:00
medmunds
e0cca8c3ed Docs: update Mandrill webhook instructions
* Mandrill now refers to "whitelist change" events
  (used to be "whitelist sync").
* More details on solving validation failures due to
  webhook url mismatches.
2017-02-01 14:42:07 -08:00
medmunds
966511474c Docs: show "unreleased" warning on latest version
Fixes #52
2017-01-26 13:55:53 -08:00
medmunds
9e641169e3 Docs: update readme and index
* Remove readme link to unreleased dev docs
* Match pre-1.0 disclaimer in docs index
  to earlier update in readme
2017-01-26 12:09:53 -08:00
medmunds
1e09b61a27 Docs: remove old copyright year 2017-01-26 11:43:28 -08:00
medmunds
33fdd0fb49 Docs: update multiple backend example
get_connection kwargs example was no longer
valid with switch to SendGrid v3 API.
2017-01-22 10:35:56 -08:00
medmunds
79288603fb Rename EmailBackends for Django consistency
* **Future breaking change:**
  Rename all Anymail backends to just `EmailBackend`,
  matching Django's naming convention.
  (E.g., switch to "anymail.backends.mailgun.EmailBackend"
  rather than "anymail.backends.mailgun.MailgunBackend".)

  The old names still work, but will issue a DeprecationWarning
  and will be removed in some future release.

  (Apologies for this change; the old naming convention was
  a holdover from Djrill, and I wanted consistency with
  other Django EmailBackends before hitting 1.0.)

Fixes #49.
2017-01-20 15:47:37 -08:00
Mike Edmunds
e568e50d0c SendGrid: update to new v3 send API (#50)
SendGrid: update to v3 send API

**SendGrid:** **[possibly-breaking]** Update SendGrid backend to newer Web API v3. This should be a transparent change for most projects. Exceptions: if you use SendGrid username/password auth, esp_extra with "x-smtpapi", or multiple Reply-To addresses, please review the [porting notes](http://anymail.readthedocs.io/en/latest/esps/sendgrid/#sendgrid-v3-upgrade).

Closes #28
2017-01-19 14:29:15 -08:00
medmunds
146afbaf3b Simplify Mandrill webhook validation handshake.
Anymail was requiring Mandrill's webhook authentication key for the initial webhook url validation request from Mandrill, but Mandrill doesn't issue the key until that validation request succeeds.

* Defer complaining about missing Mandrill webhook key until actual event post.
* Document the double-deploy process required to set up Mandrill webhooks.

Fixes #46.
2016-12-16 14:24:46 -08:00
medmunds
52596394cc Support Postmark delivery event webhook.
Add support for Postmark's recently-released [delivery tracking webhook] to Anymail's normailized status event handling. The existing Anymail tracking webhook URL can be copied to "Delivery webhook" in your Postmark outbound server settings.

Closes #45.
2016-12-15 14:24:10 -08:00
medmunds
d0596d100b Raise error for invalidly-formatted email addresses.
A message's `from_email` and each address in its `to`, `cc`, and `bcc` lists must contain exactly one email address. Previous code would silently ignore additional addresses, leading to unusual behavior. Now, raises new `AnymailInvalidAddress` exception.

Example: `from_email='Widgets, Inc. <widgets@example.com>'` is invalid: it needs double-quotes around the "Widgets, Inc." display-name portion. In earlier versions, this probably would have sent the message from something like "From: Widgets <@localhost>". Now, it will raise an exception.

**Potentially-breaking change:** If your code is using an unquoted display-name containing a comma in an email address, it will now raise an error. In earlier versions, this may have appeared to succeed, but was almost certainly not doing what you intended.

Fixes #44.
2016-12-15 13:57:49 -08:00
medmunds
e78410eea4 Docs: remove references to future inbound handling
(Postponed -- see discussion or vote to reopen in #4)

[ci skip]
2016-11-01 11:46:49 -07:00
medmunds
1cced97f65 Docs: clarify INSTALLED_APPS
* Trailing comma after "anymail" (see #40)
* Note order doesn't matter
* Change tuple to list (match examples to
  Django 1.9+ project template)

[ci skip]
2016-11-01 11:36:50 -07:00
medmunds
bbca9ab126 Docs: add tip on dynamically choosing backend
Ref #31.

[ci skip]
2016-10-25 11:21:17 -07:00
medmunds
7248c3441e Postmark: add track_clicks support
Closes #38
2016-10-23 10:54:59 -07:00
medmunds
60dc11559d AnymailMessage: initialize anymail_status to empty AnymailStatus
Allows clients that use AnymailMessage or AnymailMessageMixin
to access (e.g.) message.anymail_status.message_id without
an AttributeError, even when using a non-Anymail backend
(e.g., during testing).

Also clarify docs of anymail_status attribute to note it only gets
attached to a normal Django EmailMessage when sent through
an Anymail backend.

(May help with situation described in #36)
2016-10-20 11:50:31 -07:00
medmunds
a1380b82f3 SendGrid: force empty text and html to " " with template_id
Work around an unexpected limitation in SendGrid template
rendering, where template text or html bodies are omitted
if the supplied message text or html is "". Changing empty
string to " " works around the issue.

https://sendgrid.com/docs/API_Reference/Web_API_v3/Transactional_Templates/smtpapi.html#-Text-or-HTML-Templates

Closes #32
2016-10-13 15:15:37 -07:00
Pierre Drescher
ac3c1cbf1a Fix typo on documentation for 'recipients' attribute (#35) 2016-10-05 16:16:35 -07:00
medmunds
fb21c0d25b Mailgun: Add MAILGUN_SENDER_DOMAIN setting
Allow custom MAILGUN_SENDER_DOMAIN in Anymail
settings. (Replaces need to use global esp_extra.)

Improve docs to cover cases where this is needed.

(esp_extra sender_domain is still supported for
overriding individual messages.)

Fixes #26.
2016-08-03 14:19:35 -07:00
medmunds
f95be248ec SparkPost: remove empty content params with template_id
When using a stored template, SparkPost disallows
subject, text, and html. Django's EmailMessage default
empty strings are enough to provoke "Both content
object and template_id are specified" from SparkPost,
so remove them (if empty) when using stored templates.

Update docs and tests; add integration test for template_id.

Fixes #24
2016-06-24 12:13:32 -07:00
Mike Edmunds
db101bf6b9 Add SparkPost support (#20)
Implement SparkPost backend and tracking webhooks.

Closes #11.
2016-06-22 15:31:30 -07:00
medmunds
742868d68c Docs: missed param in pre_send signature
[ci skip]
2016-05-13 12:17:27 -07:00
medmunds
f8eafba0df Add pre_send and post_send signals
Closes #8
2016-05-12 21:18:04 -07:00
medmunds
d4f6ffbb41 Show DeprecationWarning, etc. in runtests
Install default warnings filter in test runs, to avoid
python's default suppression of DeprecationWarning
and other "intended for developer" warnings.

(Avoids need to provide -Wd or -Wall arg to runtests.)
2016-05-12 17:42:44 -07:00
medmunds
a0b92bee7a Mandrill: support esp_extra
* Merge esp_extra with Mandrill send payload
* Handle pythonic forms of `recipient_metadata`
  and `template_content` in esp_extra
* DeprecationWarning for Mandrill EmailMessage
  attributes inherited from Djrill
2016-05-11 15:08:57 -07:00
Linus Schoemaker
23353de8e6 Fix syntax error in installation instructions 2016-05-09 11:34:04 +02:00
medmunds
75730e8219 Add ESP templates, batch send and merge
* message.template_id to use ESP stored templates
* message.merge_data and merge_global_data
  to supply per-recipient/global merge variables
  (with or without an ESP stored template)
* When using per-recipient merge_data, tell ESP to use
  batch send: individual message per "to" address.
  (Mailgun does this automatically; SendGrid requires
  using a different "to" field; Mandrill requires
  `preserve_recipients=False`; Postmark doesn't
  support *this type* of batch sending with merge data.)
* Allow message.from_email=None (must be set after
  init) and message.subject=None to suppress those
  fields in API calls (for ESPs that allow "From" and
  "Subject" in their template definitions).

Mailgun:
* Emulate merge_global_data by copying to
  recipient-variables for each recipient.

SendGrid:
* Add delimiters to merge field names via
  esp_extra['merge_field_format'] or
  ANYMAIL_SENDGRID_MERGE_FIELD_FORMAT setting.

Mandrill:
* Remove Djrill versions of these features;
  update migration notes.

Closes #5.
2016-05-06 12:27:11 -07:00
medmunds
1372ef21eb SendGrid: merge 'filters' in esp_extra
Previously, setting esp_extra['x-smtpapi']['filters']
would override the entire filters setting, potentially
undoing other Anymail options that use SendGrid
filters (like track_opens).

Now, 'filters' is special-cased, and merged with
any other Anymail filter options.

(We don't do a fully deep merge, because otherwise
there would be no way to use esp_extra to *clear*
Anymail settings.)
2016-04-30 10:21:11 -07:00
medmunds
d3f914be12 Event-tracking webhooks
Closes #3
2016-04-29 18:10:50 -07:00
medmunds
df881fdb75 Allow kwargs overrides for (nearly) all settings
* Update utils.get_anymail_setting to support
  kwargs override of django.conf.settings values
* Use the updated version everywhere
* Switch from ImproperlyConfigured to
  AnymailConfigurationError exception
  (anticipates feature_wehooks change)

Closes #12
2016-04-29 14:34:34 -07:00
medmunds
6b415eeaae Docs: note limited Mandrill support
Mandrill has disabled our test account and API key,
so future development will be purely against their docs.

[ci skip]
2016-04-29 11:21:11 -07:00
medmunds
8e43f29944 Workaround missing smtp-id in SendGrid tracking.
* Add smtp-id in unique_args (metadata), to ensure
  it shows up in click and open events.
* Add SENDGRID_GENERATE_MESSAGE_ID setting,
  default True, to control auto-Message-ID behavior.
* Document it.
2016-04-29 09:44:31 -07:00
Mike Edmunds
ca7dbdcec6 Docs: clarify ESP templates not yet implemented 2016-04-26 09:39:41 -07:00
medmunds
385d76b53a Move tests out of app module
(Directory structure as suggested in
[Django testing docs][1].)

[1]: https://docs.djangoproject.com/en/1.9/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications
2016-03-21 11:38:58 -07:00
medmunds
12229ab116 Docs: make ESP feature matrix maintainable
(reST substitutions bring the table width back within
a normal editor's width!)

[ci skip]
2016-03-14 19:48:47 -07:00