Skip to content

feat(newsletter): add List-Unsubscribe headers and RFC 8058 one-click handler - #488

Merged
thisismeonmounteverest merged 1 commit into
masterfrom
neophytis/newsletter-list-unsubscribe-headers
Aug 31, 2026
Merged

feat(newsletter): add List-Unsubscribe headers and RFC 8058 one-click handler#488
thisismeonmounteverest merged 1 commit into
masterfrom
neophytis/newsletter-list-unsubscribe-headers

Conversation

@Neophytis

Copy link
Copy Markdown
Contributor

Summary

  • Mailer::sendNewsletterEmail(): now emits three bulk-mail headers on every regular newsletter send:
    • Precedence: bulk — standard signal for mass mail
    • List-Unsubscribe: <https://...> — personalised per recipient using the existing unsubscribe token (required by Google/Yahoo since Feb 2024 for senders over 5,000/day)
    • List-Unsubscribe-Post: List-Unsubscribe=One-Click — enables Gmail's one-click unsubscribe button
  • Transactional sends (reminder, suspension notification, Terms of Use) are excluded from bulk headers.
  • SubscriptionController::unsubscribeNewsletter(): handles RFC 8058 one-click POST requests (body List-Unsubscribe=One-Click) sent by Gmail when a user clicks the unsubscribe button, immediately suppressing the address with a 200 response and no confirmation page.

Implementation notes

sendTemplateEmail() gains an array $extraTextHeaders = [] parameter (backward-compatible default). A new private buildNewsletterHeaders() method constructs the header map, returning empty for transactional types or when no unsubscribe key is present.

The unsubscribe URL is generated via the existing regular_newsletter_unsubscribe route with the per-recipient unsubscribe_key already passed through SendMassmailCommand.

Test plan

  • Send a test newsletter to a personal address; confirm List-Unsubscribe, List-Unsubscribe-Post, and Precedence appear in raw headers
  • Verify the unsubscribe URL in the header resolves to the correct member's unsubscribe page
  • POST to the unsubscribe URL with body List-Unsubscribe=One-Click; confirm 200 and that the member is unsubscribed
  • Send a reminder/suspension notification; confirm none of the bulk headers appear

…T handler

Adds bulk-mail headers required by Google/Yahoo since Feb 2024 to all
regular newsletter sends: List-Unsubscribe (personalised per recipient
using the existing unsubscribe token), List-Unsubscribe-Post for Gmail's
one-click unsubscribe button, and Precedence: bulk.

Transactional sends (reminder, suspension, TOU) are excluded.

Also handles RFC 8058 one-click POST requests in SubscriptionController
so Gmail's unsubscribe button works without a confirmation page.
@thisismeonmounteverest
thisismeonmounteverest merged commit 893caed into master Aug 31, 2026
4 of 12 checks passed
@thisismeonmounteverest
thisismeonmounteverest deleted the neophytis/newsletter-list-unsubscribe-headers branch August 31, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants