Commit Graph

140 Commits

Author SHA1 Message Date
Mike Edmunds
567fbb52ab Amazon SES: Fix header encoding problem
A combination of long display name and
commas (or other special characters) could
result in invalid address headers.
See details in #369.

Fix by removing unnecessary email.policy
override, which was causing new header folding
code to run with headers built using Compat32
legacy header encoding. The two don't mix.

Fixes #369
2024-06-22 16:52:45 -07:00
Mike Edmunds
c4b2e08b16 SparkPost: error on features incompatible with template_id
Raise an `AnymailUnsupportedFeature` error
when trying to use a `template_id` along with
other content payload fields that SparkPost
silently ignores when template_id is present.
2024-06-22 14:47:51 -07:00
Mike Edmunds
faf98c22d7 MailerSend: support extra headers
MailerSend added a `"headers"` API field
(which is available to "Enterprise
accounts only").
2024-06-21 17:41:33 -07:00
Mike Edmunds
0776b12331 Feature: Implement merge_headers
Implement and document `merge_headers`
for all other ESPs that can support it. (See #371
for base and Amazon SES implementation.)

Closes #374
2024-06-20 15:31:58 -07:00
Mike Edmunds
0f2eef7300 Amazon SES: support headers with template
Use new SES v2 SendBulkEmail ReplacementHeaders param
to support features that require custom headers,
including `extra_headers`, `metadata`,
`merge_metadata` and `tags`.

Update integration tests and docs

Closes #375
2024-06-08 13:29:09 -07:00
Rodrigo Nicolas Carreras
33f680686b Add merge_headers option for Amazon SES
Add new `merge_headers` message option 
for per-recipient headers with template sends. 

* Support in base backend
* Implement in Amazon SES backend
  (Requires boto3 >= 1.34.98.)

---------

Co-authored-by: Mike Edmunds <medmunds@gmail.com>
2024-05-21 11:55:29 -07:00
Mike Edmunds
daef82c158 Amazon SES: improve missing client error 2024-05-16 11:37:19 -07:00
Mike Edmunds
abb984485b Amazon SES: remove deprecated v1 support
- Remove deprecated amazon_sesv1 EmailBackend
- Remove deprecated amazon_sesv2 alias
  for amazon_ses EmailBackend
- Update docs
2024-03-12 13:38:45 -07:00
Mike Edmunds
948ab2be27 Brevo: SendinBlue compatibility
(See previous commit.)

- Maintain deprecated compatibility
  versions on the old names/URLs.
  (Split into separate commit
  to make renamed files more
  obvious.)
2024-03-11 18:51:39 -07:00
Mike Edmunds
c7ee59c3ca Brevo: Rename SendinBlue to Brevo
- Replace "SendinBlue" with "Brevo"
  throughout the code.
- Maintain deprecated compatibility
  versions on the old names/URLs.
  (Split into separate commit
  to make renamed files more
  obvious.)
- Update docs to reflect change,
  provide migration advice.
- Update integration workflow.
2024-03-11 18:46:52 -07:00
Arondit
a71a0d9af8 Unisender Go: new ESP
Add support for Unisender Go

---------

Co-authored-by: Mike Edmunds <medmunds@gmail.com>
2024-03-05 11:38:40 -08:00
Mike Edmunds
706fce60ac Resend: support batch send
Add support for `merge_metadata`
and new Resend email/batch API.
2024-02-19 16:41:22 -08:00
Mike Edmunds
4f305131ee Brevo: add batch send support
Closes #353
2024-02-19 11:52:10 -08:00
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
f911ee78a0 Fix Python 3.12 deprecation warning 2023-09-22 11:08:20 -07:00
Mike Edmunds
05afde0651 SendGrid: support multiple reply_to
Closes #325
2023-07-27 18:37:31 -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
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
9fba58237d Drop support for Python 3.6 and old urllib3 2023-05-02 13:59:01 -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
62bd0669af MailerSend: add support (new ESP for Anymail)
Closes #298
2023-03-10 17:22:20 -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
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
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
David Gilman
e3cd4df1fc Allow requests session customization, document use for automatic retries
* Refactor create_session() out of AnymailRequestsBackend
* Document automatic retries with Requests
2022-06-26 18:52:46 -07: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
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
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
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
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
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
medmunds
feee8b5c5a Cleanup: simplify requests backend raise_for_status
Treat all 2xx (not just 200) as success in base
AnymailRequestsBackend.raise_for_status, eliminating
some unnecessary subclass overrides.
2020-09-11 14:26:55 -07:00
medmunds
a14276e765 Cleanup: remove unused MailjetPayload property 2020-09-11 14:26:55 -07:00
medmunds
985143b234 SparkPost: add subaccount support 2020-09-11 11:10:24 -07:00
medmunds
61660cd5ff SparkPost: call HTTP API directly [breaking]
Switch from the (now unmaintained) python-sparkpost
client library to a requests-based backend that calls
SparkPost's Transmissions API directly.

Also adds support for text/x-amp-html alternative parts
(which are supported by the SparkPost API, but weren't
by the client library).

Closes #203
2020-09-11 11:10:24 -07:00
Mike Edmunds
bc1156149a Mailjet: Upgrade to Send API v3.1 [breaking]
Switch from Mailjet's older v3.0 Send API to the newer v3.1 version.

This is a breaking change for code using the Mailjet backend and:
* Using `esp_extra`, which must be updated to the new API format
* Using multiple `reply_to` addresses, which the v3.1 API doesn't allow

Closes #81
2020-09-08 14:50:26 -07:00
Mike Edmunds
85cec5e9dc Drop Python 2 and Django 1.11 support
Minimum supported versions are now Django 2.0, Python 3.5.

This touches a lot of code, to:
* Remove obsolete portability code and workarounds
  (six, backports of email parsers, test utils, etc.)
* Use Python 3 syntax (class defs, raise ... from, etc.)
* Correct inheritance for mixin classes
* Fix outdated docs content and links
* Suppress Python 3 "unclosed SSLSocket" ResourceWarnings
  that are beyond our control (in integration tests due to boto3, 
  python-sparkpost)
2020-08-01 14:53:10 -07:00
medmunds
c4ed6660b3 Mailjet: fix TypeError in sanitize_address
Fix TypeError when sending to or from addresses with
display names containing commas. Rewrite Anymail's
workaround for Mailjet's problem with commas in display
names, to avoid calling Django's internal sanitize_address
in an unsupported way.

The TypeError results from Django changes that will be
introduced in Django 2.2.15, 3.0.9, and 3.1.
2020-07-23 13:19:17 -07:00
medmunds
35792354b3 Amazon SES: fix bcc
Set SendRawEmail Destinations param to pick up all
recipients, including bcc (which doesn't appear in
message headers).

Fixes #189
2020-07-22 13:42:48 -07:00
jc-ee
2a36da54e6 Postmark: Fix sending templated email to a single recipient
Fix a bug where sending an email with a template_id and a single to address
would cause a Postmark API error.

Thanks @jc-ee for finding and fixing.
2020-04-13 13:48:37 -07:00
Mike Edmunds
920d8dd70f SendGrid: Fix multiple recipients with only merge_global_data
In SendGrid backend, support non-batch template send to multiple
recipients when `merge_global_data` is set without `merge_data`.
Regression introduced in v6.0.

Fixes #179
2020-03-18 17:08:10 -04:00