Commit Graph

215 Commits

Author SHA1 Message Date
Mike Edmunds
b5ef492466 Resend: new ESP (#341)
Add support for Resend.com backend and webhooks.

Closes #341
2023-10-25 12:23:57 -07:00
Mike Edmunds
823a161927 Fix global SEND_DEFAULTS merging
Replace generic `combine` with
specific `merge_dicts_deep`,
`merge_dicts_shallow`,
`merge_dicts_one_level` or
`concat_lists`, depending on
appropriate behavior for each
message attribute.

Fixes merging global `SEND_DEFAULTS`
with message `esp_extra` for ESP APIs
that use nested payload structures.
And clarifies intent for other properties.
2023-10-19 14:33:50 -07:00
Mike Edmunds
05afde0651 SendGrid: support multiple reply_to
Closes #325
2023-07-27 18:37:31 -07:00
Mike Edmunds
c8a5e13c89 Brevo: add inbound support
(Also adds "responses" to test requirements,
for mocking fetches of Brevo inbound
attachments.)

Closes #322
2023-07-27 18:26:57 -07:00
Léo Martinez
0ac248254e Inbound: improve inline content handling
* refactor: derive `AnymailInboundMessage` from `email.message.EmailMessage`
  rather than legacy Python 2.7 `email.message.Message`

* feat(inbound): replace confusing `inline_attachments` with `content_id_map`
  and `inlines`; rename `is_inline_attachment` to `is_inline`; deprecate old names 

Closes #328

---------

Co-authored-by: Mike Edmunds <medmunds@gmail.com>
2023-07-27 15:10:58 -07:00
Mike Edmunds
bc8ef9af0f Tests: update Postmark integration
Postmark has changed their error message
for invalid server token. (Also, we don't
care about the specific error code, just
that the error is caught and reported.)
2023-06-27 12:25:13 -07:00
Mike Edmunds
4f4461af4d Tests: update Mandrill integration
Mandrill has changed status code for
invalid from_email from 500 to 400.
(We don't actually care about the specific
code, just that the error is caught and
reported.)
2023-06-27 12:23:35 -07:00
sblondon
8a72f89e8a Sendinblue: rename to Brevo
* Update docs to (usually) refer to Brevo rather than Sendinblue
* Change SENDINBLUE_API_URL to api.brevo.com
   (same API is available on both domains)
* Leave code references (settings, backend name, webhook urls)
   unchanged as `sendinblue`, to avoid unnecessary client changes
2023-06-13 13:04:52 -07:00
Mike Edmunds
744d467f70 Postmark inbound: improve inbound parsing
- Support Postmark's RawEmail option;
  recommend it in docs
- Handle Bcc when provided by Postmark
- Obtain `envelope_sender` from Return-Path info
  Postmark now adds, rather than parsing Received-SPF

Related:
- Add `AnymailInboundMessage.bcc` convenience prop
- Test against full Postmark "check" inbound payloads
  (which don't match their docs or real inbound payloads)
- Don't warn about receiving "check" payload
2023-05-06 11:40:00 -07:00
Mike Edmunds
746cf0e24e Mandrill: drop Djrill compatibility 2023-05-04 13:08:05 -07:00
Mike Edmunds
41754d9813 Amazon SES: use SES v2 API by default
- Rename `anymail.backends.amazon_sesv2.EmailBackend`
  to `amazon_ses`, making SES v2 the default.
- Rename the old `amazon_ses` backend to `amazon_sesv1`,
  keeping it available. Add a deprecation warning.
- Alias `amazon_sesv2` to `amazon_ses`, with a
  deprecation warning (for projects that opted
  into v2 early under Anymail 9.1 or 9.2).
- Similar renaming on the test files.
- Update docs to assume v2 in most places
  (other than migration-specific sections)
2023-05-04 12:27:55 -07:00
Mike Edmunds
e8df0ec8e0 Modernize packaging
Switch to pyproject.toml packaging, using hatchling.

- Replace all uses of setup.py with updated equivalent
- BREAKING: Change extra name `amazon_ses` to
  `amazon-ses`, to comply with Python packaging
  name normalization
- Use hatch custom build hook to freeze version number
  in readme (previously custom setup.py code)
- Move separate requirements for dev, docs, tests
  into their own requirements.txt files
- Fix AnymailImproperlyInstalled to correctly refer
  to package extra name
- Update testing documentation
- Update docs readme rendering to match PyPI
  (and avoid setup.py)
- In tox tests, use isolated builds and update pip
- Remove AUTHORS.txt (it just referred to GitHub)
2023-05-03 16:55:08 -07:00
Mike Edmunds
7d993ee610 Fix fail_silently when session/client creation fails
Make sure backends actually fail silently when asked
(rather than raising inaccurate errors suggesting
coding problems).

Fixes #308
2023-05-02 12:38:18 -07:00
Mike Edmunds
1ba26e1be3 Fix empty strings in AnymailInboundMessage from/to/cc
Fix AnymailInboundMessage.to, .cc, .from_email when
message was built with AnymailInboundMessage.construct
using empty strings for those params. (Postmark inbound
relies on this.)

Fixes #307
2023-05-02 11:42:00 -07:00
Therry van Neerven
885eb9b98a Postmark: workaround invalid "test inbound" data
Postmark's "test" button in their inbound settings
posts data with attachments that don't match their docs or
actual inbound behavior. Accept that and issue a warning.

Closes #304
2023-04-22 12:00:05 -07:00
Mike Edmunds
62bd0669af MailerSend: add support (new ESP for Anymail)
Closes #298
2023-03-10 17:22:20 -08:00
Mike Edmunds
c58640d438 Mandrill: update integration test
Mandrill bad API key can respond either 401 or 500,
so don't bother checking exact status code. 
(Just make sure it results in a useful error.)
2023-03-09 09:56:42 -08:00
Mike Edmunds
ea446a94d3 Amazon SES: implement SES v2 API backend
* Add `anymail.backends.amazon_sesv2.EmailBackend` using SES v2 API
* Declare current SES v1 backend as "deprecated"

Closes #274
2023-02-26 14:16:46 -08:00
medmunds
f5f3fc86e6 Simplify url patterns
Favor `django.urls.path` over `re_path` where possible.
2023-02-08 14:23:15 -08:00
medmunds
ec864f5165 Tests: simplify test_settings maintenance
If no version-specific tests.test_settings.settings* file
exists for the current Django version, fall back to an
earlier settings file.

- runtests.py find latest settings_N_M earlier than or
  matching Django version N.M being tested, rather than
  requiring exact match
- remove test_settings files that were just duplicates
  of earlier versions
2023-02-08 11:03:06 -08:00
medmunds
f71813f820 Fix Sendinblue integration test
Fix change apparently introduced by black?
(Unclear why this didn't cause integration test failure
when run in PR branch.)
2023-02-06 15:36:29 -08:00
medmunds
b4e22c63b3 Reformat code with automated tools
Apply standardized code style
2023-02-06 15:05:24 -08:00
medmunds
287c2175f4 Sendinblue: Support send_at
Add support for delayed sending via
Sendinblue's public beta "scheduledAt"
parameter.

Closes #280
2022-12-18 15:53:45 -08:00
medmunds
681a4afe6b Sendinblue: fix "invalid headers" error
Work around recent (unannounced) Sendinblue API change
that caused "Invalid headers" API error with non-string
custom header values, by converting basic numeric types
to strings. (Borrowed code from SendGrid backend.)

Fixes #288
2022-11-04 16:46:25 -07:00
medmunds
3f05623a2f Drop support for Django 2.x and Python 3.5 2022-08-29 13:25:47 -07:00
Tim Schilling
a4f50c4340 Confirm support for Django 4.1
Replaces deprecated `django.utils.timezone.utc` with
`datetime.timezone.utc` (available since Python 3.2).
2022-08-24 13:24:27 -07:00
medmunds
6b3775a8e9 Tests: fix SparkPost integration test
SparkPost has changed http status for bad API key
from 403 Forbidden to 401 Unauthorized.
2022-07-28 14:29:29 -04:00
medmunds
748ac9fea7 Tests: fix SparkPost integration test
SparkPost has switched http status for bad API key.
2022-07-28 11:56:19 -04:00
puru02
48de044c9b Fix: Postmark tracking webhook handle SubscriptionChange events
Handle Postmark SubscriptionChange events as Anymail 
unsubscribe, subscribe, or bounce Anymail tracking events.
2022-06-07 17:28:39 -07:00
medmunds
09f21a5c2d Mailgun/SendGrid inbound: workaround Django filename issue
Workaround for Django multipart/form-data limitation
where certain attachment filenames cause fields to be dropped
or to end up in request.POST rather than request.FILES.

Handle the MultiValueDictKeyError in inbound webhooks when
this has occurred. Also update docs to recommend avoiding
the problem by using Mailgun and SendGrid's "raw MIME" options.

Also handle reported cases of empty, duplicate keys in Mailgun's
content-id-map.

Fixes #272
2022-05-13 10:19:12 -07:00
medmunds
ddeb938a3c Mandrill: re-enable integration tests
Get Mandrill integration tests working again,
by using a test-mode API key and a trial account.
2022-02-02 16:36:11 -08:00
medmunds
41147b581c Mandrill: don't send unnecessary empty fields
Don't add empty Reply-To header and empty display names
to Mandrill send API data.

Fixes #262
2022-02-02 16:36:11 -08:00
Mike Edmunds
5fdc285e82 CI/Docs: move to anymail.dev
Move all integration tests and contact emails to anymail.dev. 
(Stop using anymail.info.)
2022-02-02 13:59:09 -08:00
medmunds
dc0a46a815 Feature: add is_batch_send to anymail_test_params
Make it easier for tests to check whether messages
would fall under Anymail's batch-send logic.

See #249.
2022-01-11 19:54:39 -08:00
medmunds
10f569cd50 Fix: don't include sender/recipient in AnymailError description
Remove `AnymailError.describe_send`, which added sender and
recipient email addresses to every AnymailError message
(whether or not relevant to the error).

Addresses #245
2022-01-11 17:03:03 -08:00
medmunds
60fbe1e896 Fix: treat first text/plain alternative as plaintext body
Improve handling of alternative parts and `content_subtype`
to match how Django's SMTP backend handles some unusual cases.

Change Test backend to support (and record) text/* alternative
parts. (But still reject other types of alternatives.)

Fixes #252
2022-01-10 15:35:00 -08:00
medmunds
8b0425f784 CI: Refactor workflows, update test matrix
* Split test, integration-test, and release workflows,
  simplifying config and logic for each.
* Use environment to separate secrets for release workflow.
* Update test matrix with newer Django and Python versions.
2022-01-10 13:42:45 -08:00
Mike Edmunds
adc92f037b Tests: tox and mock cleanup
* Remove mock dependency
  (mock is now part of standard unittest package)
* Cleanup tox dependency installation logic
2021-06-13 12:13:31 -07:00
Tilmann Becker
e90c10b546 Add Postal support
Thanks to @tiltec for researching, implementing, testing and documenting it.
2021-06-07 17:11:35 -07:00
Mike Edmunds
44754c908e Postmark: fix silent failures for send-time validation errors
Postmark uses their ErrorCode 300 to report several different
send-time validation errors, some of which identify invalid
recipients that need to be handled specially, but many of which
are ordinary API errors.

Rework the logic for parsing ErrorCode 300 error messages:
Handle only "Invalid 'To'" or "Error parsing 'To'" (or 'Cc'
or 'Bcc') as recipient errors. Otherwise raise an API error.

Fixes #238 silent failure when sending with long metadata keys.
2021-05-19 13:15:34 -07:00
Mike Edmunds
b1a4f9809a Amazon SES: confirm webhook subscriptions in SNS topic's own region (#236)
Allow inbound and tracking webhooks using SNS topics from any AWS region.
The topic subscription must be confirmed in the topic's own region (not
the boto3 default), determined by examing the topic's ARN.

Fixes #235
2021-04-11 13:02:56 -07:00
medmunds
f4c99abddf Postmark: Fix incorrect single 'to' handling with template but no merge data
Fixes #227
2021-02-24 12:30:05 -08:00
medmunds
9ed5ce0213 Postmark: Fix API error with template but no merge data
Fixes #223
2021-02-22 17:50:46 -08:00
medmunds
d1ef61d3ba Mailgun: add AMPHTML support 2021-01-27 14:37:16 -08:00
medmunds
d33c9ea4ed Mailgun: improve API error messages 2021-01-27 14:37:16 -08:00
medmunds
f039366bf0 Test against Django 3.2 prerelease
* Omit default_app_config under Django 3.2 and later
  to avoid DeprecationWarning
* Also adds testing on Python 3.9, 3.10-alpha
* Also updates test matrix to include all supported
  Python versions (some older Django versions expanded
  Python support in patch releases)
2021-01-26 13:55:17 -08:00
medmunds
fb5912f0e7 Internal: validate AnymailRecipientStatus at init
Catch invalid message_id and status when initializing
AnymailRecipientStatus, so problems with ESP response
are caught earlier (in individual backend
parse_recipient_status, rather than base backend _send).
2021-01-26 13:55:17 -08:00
Mike Edmunds
5cbaa24002 Move CI testing to GitHub Actions
Related changes:
* remove Travis-CI config; stop running tests on Travis
* rename live integration test environment variables
  to all start with `ANYMAIL_TEST_` (simplifies tox config)
2020-11-28 18:08:01 -08:00
Mike Edmunds
8c1749c6f3 SparkPost: drop support for multiple from_email (#213)
SparkPost's API no longer allows this, and now returns
a confusing error message about return_path.

(Not treating as a breaking change in Anymail, because
the breaking change was in the SparkPost API. This just
improves the error message in the unlikely event anyone
is trying to use this feature.)

Closes #212
2020-11-28 18:02:59 -08:00
slinkymanbyday
b9fdd3a37e SparkPost: initial open and AMP tracking events
* Add SPARKPOST_TRACK_INITIAL_OPEN_AS_OPENED boolean
  setting, default False, controlling whether to report
  SparkPost "Initial Open" events as Anymail "opened".
* Add mapping for SparkPost "AMP Click", "AMP Open",
  and "AMP Initial Open" events.
* Update outdated doc references to SparkPost site

Closes #206
2020-09-18 15:25:25 -07:00