Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: per-recipient merge_headers #374

Closed
medmunds opened this issue May 21, 2024 · 0 comments · Fixed by #380
Closed

New feature: per-recipient merge_headers #374

medmunds opened this issue May 21, 2024 · 0 comments · Fixed by #380

Comments

@medmunds
Copy link
Contributor

medmunds commented May 21, 2024

Several ESPs' batch send APIs allow specifying different email headers for individual recipients. Anymail should add a new merge_headers message option providing normalized support for this feature:

message = AnymailMessage(
    to=["alice@example.com", "Bob <bob@example.com>"],
    ...,
    # Common headers for all recipients:
    headers={
        "List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
    },
    # Recipient-specific headers:
    merge_headers={
        "alice@example.com": {
            "List-Unsubscribe": "<https://example.com/unsubscribe/98765abc>",
        },
        "bob@example.com": {
            "List-Unsubscribe": "<https://example.com/unsubscribe/12345xyz>", 
        },
    },
)

As the example shows, this is particularly useful for List-Unsubscribe headers that include a token identifying the recipient. The new merge_headers property is meant to parallel Anymail's existing merge_metadata and merge_data.

[Edit: updated info on supported ESPs]

Can support merge_headers:

  • Amazon SES (only works with template API)
  • Brevo
  • Mailgun (using recipient-variables substitutions)
  • Mailjet
  • Postmark
  • Resend
  • SendGrid
  • SparkPost (using substitutions)
  • Unisender Go (using substitutions, for List-Unsubscribe header only)

Cannot support merge_headers:

In addition to providing the idea, @carrerasrodrigo has already implemented the base and Amazon SES support in #371. (Thanks!)

medmunds added a commit that referenced this issue Jun 20, 2024
Implement and document `merge_headers`
for all other ESPs that can support it. (See #371
for base and Amazon SES implementation.)

Closes #374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant