Skip to content

Support custom email headers via sendRawEmail - #63

Open
joehoyle wants to merge 1 commit into
masterfrom
feature/raw-email-custom-headers
Open

Support custom email headers via sendRawEmail#63
joehoyle wants to merge 1 commit into
masterfrom
feature/raw-email-custom-headers

Conversation

@joehoyle

Copy link
Copy Markdown
Member

Summary

  • When wp_mail() is called with non-standard headers (e.g. List-Unsubscribe, List-Unsubscribe-Post, X-*), automatically switch from sendEmail to sendRawEmail which preserves them in the raw MIME message
  • Standard emails without custom headers continue using sendEmail as before — no change in behavior for existing usage
  • Needed for RFC 8058 one-click unsubscribe support (Gmail, Yahoo, Apple Mail)

Test plan

  • Send an email via wp_mail() without custom headers — should use sendEmail as before
  • Send an email with List-Unsubscribe header — should use sendRawEmail and header should appear in "View Original" in Gmail
  • Verify CC, BCC, Reply-To still work correctly in raw email path

🤖 Generated with Claude Code

The sendEmail API doesn't support custom headers like
List-Unsubscribe. When non-standard headers are passed to wp_mail(),
automatically switch to sendRawEmail which preserves them in the
raw MIME message. Standard emails without custom headers continue
using sendEmail as before.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rmccue

rmccue commented Feb 16, 2026

Copy link
Copy Markdown
Member

Any reason not to always use sendRawEmail? Seems like sendEmail might be more of a convenience abstraction anyway.

@joehoyle

Copy link
Copy Markdown
Member Author

Yeah mostly I was being conservative not to break anything :D

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