Repository navigation
fix(mails): gate session alert custom template on SMTP enabled - #15055
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The session alert listener applied the stored custom subject and body even when the project's custom SMTP was disabled, so the mail went out through the platform SMTP with the custom content. Every other mail path only applies custom templates when custom SMTP is enabled; do the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This change ensures the session-alert email uses the built-in locale default template when a project has no enabled SMTP configuration, so custom templates are only applied when the project controls its own mail delivery. A new e2e test helper creates two sessions and asserts the alert renders the correct template on each side.
Reviewed commit: 8ae87f4 |
🟢 Tier S · Ready to merge
Session alert custom subject and body templates are now resolved only when the project has custom SMTP enabled. The Templates e2e coverage exercises both the disabled-SMTP default-template path and the enabled-SMTP custom-template path.
📂 Walkthrough · 2
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What
The session alert listener (
src/Appwrite/Bus/Listeners/Mails.php) applied a project's stored customsessionAlertsubject and body regardless of whether the project's custom SMTP was enabled. Only the SMTP config itself was gated onsmtp.enabled. With SMTP disabled the alert was sent through the platform SMTP sender, carrying the custom content.Every other mail path (verification, recovery, magic URL, OTP, MFA, team invites) only applies a custom template when custom SMTP is enabled. Disabling SMTP does not clear stored templates, so the session alert was the one path where a custom template could be delivered through the platform sender.
Fix
Resolve the custom template only when
smtp.enabledis true; otherwise the default session alert template is used. Sender/reply-to overrides were already inside the SMTP gate.Tests
New e2e
testSessionAlertIgnoresCustomTemplateWhenSMTPDisabledintests/e2e/Services/Project/TemplatesBase.php(runs for bothTemplatesConsoleClientTestandTemplatesCustomServerTest):sessionAlerttemplate, disable SMTP, trigger an alert: the mail uses the default subject and does not contain the custom body (failed before the fix, passes after)Existing
testSessionAlertUsesCustomTemplatePerLocaleand the full Templates suites pass.Tracking: appwrite-labs/cloud#7052
🤖 Generated with Claude Code