Skip to content

feat(mails): pass custom headers through the mail queue - #13851

Merged
lohanidamodar merged 4 commits into
mainfrom
feat/mail-headers
Sep 23, 2026
Merged

lohanidamodar merged 4 commits into
mainfrom
feat/mail-headers

Conversation

@lohanidamodar

@lohanidamodar lohanidamodar commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Adds a generic headers field to Event\Message\Mail. The Mails worker passes it to Messages\Email from utopia-php/messaging 2.5. Payloads queued without the key decode to []. A malformed header throws messaging's header_malformed: that covers CR/LF, a name the message owns, or a name that duplicates another by case. The existing catch then marks the mail skipped without retrying it.

Appwrite Cloud uses this to send RFC 8058 List-Unsubscribe / List-Unsubscribe-Post headers on non-essential console mail.

Bumps utopia-php/messaging to ^2.5, which adds Email headers support (utopia-php/monorepo#328). Only messaging moves in the lock.

Tests:

  • Unit test for the message round trip, including a payload queued before the field existed.
  • The worker change has no unit test, because workers are covered E2E. The Cloud E2E suite checks that the headers arrive at maildev.

Related draft PRs:

Mail::headers rides the queue payload (Base64 JSON) so the Mails
worker can hand List-Unsubscribe and other custom headers to
Messages\Email. Pins utopia-php/messaging to the unmerged
feat/messaging-email-headers branch via a dev alias (2.4.999) since
the release carrying the headers arg isn't tagged yet; swap for a
tagged ^2.5 once it ships.
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/mail-headers (after).

Metric Before After Change
🚀 Requests/sec 164.11 159.46 ⚪ -2.8%
⏱️ Latency P50 103.76 ms 107.68 ms ⚪ +3.8%
⏱️ Latency P95 256.11 ms 259.66 ms ⚪ +1.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 107.68 259.66 10,203 159.46 +3.55
Account 212.15 427.28 537 8.94 -3.11
TablesDB 105.05 211.27 5,549 88.79 +2.74
Storage 95.19 208.14 2,685 44.49 -13.79
Functions 148.17 311.04 1,432 24.24 -10.49

Top API waits (after)

API request Max wait (ms)
account.prefs.update 605.1
account.name.update 602.27
functions.variables.delete 479.7
tablesdb.rows.create 465.62
functions.delete 458.29

@lohanidamodar
lohanidamodar marked this pull request as ready for review September 23, 2026 10:50
@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the mail producer, queue payload, worker, and updated messaging dependency aligned.

Summary

Adds custom email headers to the system-mail queue contract and forwards them to the messaging email adapter.

  • Serializes and restores the optional headers field while retaining compatibility with older queued payloads.
  • Passes queued headers into Messages\Email.
  • Upgrades utopia-php/messaging to 2.5.0 for custom-header support.
  • Adds coverage for the publisher-to-queue payload boundary and legacy payload decoding.

Reviews (2) · Last reviewed commit: "test(mails): assert headers on the queue..."

Comment thread tests/unit/Event/Message/MailTest.php Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified, and compatibility and test coverage are included.

Review effort: Lite
Findings: None

What changed in this PR

Adds optional custom email headers to queued mail messages and forwards them through the mail worker.

Changes:

  • Adds backward-compatible header serialization.
  • Passes headers to outgoing email messages.
  • Updates the messaging dependency and tests.
File Description
tests/​unit/​Event/​Message/​MailTest.php Tests header persistence and legacy payload compatibility.
src/​Appwrite/​Platform/​Workers/​Mails.php Forwards headers to email messages.
src/​Appwrite/​Event/​Message/​Mail.php Adds header queue serialization support.
composer.lock Locks the updated messaging dependency.
composer.json Requires messaging 2.5+.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@lohanidamodar
lohanidamodar merged commit 1e55897 into main Sep 23, 2026
62 checks passed
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.

3 participants