Skip to content

Backend/emails: Support custom SMTP headers for attachments#8665

Merged
tristanlabelle merged 7 commits into
developfrom
backend/bugfix/email-attachments-headers
May 26, 2026
Merged

Backend/emails: Support custom SMTP headers for attachments#8665
tristanlabelle merged 7 commits into
developfrom
backend/bugfix/email-attachments-headers

Conversation

@tristanlabelle

@tristanlabelle tristanlabelle commented May 17, 2026

Copy link
Copy Markdown
Contributor

ics attachments are trickier than I thought, one of the ics field (method) also needs to be replicated as an SMTP header on the attachment for correct support by email clients. EmailAttachment wasn't flexible enough to represent this, so I switched it over to specifying the Content-Type and Content-Disposition headers directly, which is as generic as it gets. This should improve calendar event compatibility and behavior in email clients.

There's some extra dance to support unquoted method=XXX in the SMTP header (not the default Python behavior) since Gemini said that was preferred for backcompat with old email clients.

Testing

Ran locally, accepted host requests and downloaded emails from MailDev while iterating until I got this desired form for the attachment:

--===============2710363521157735036==
Content-Type: text/calendar; charset="utf-8"; method=PUBLISH
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="host_request.ics"
MIME-Version: 1.0

Backend checklist

  • Added tests for any new code or added a regression test if fixing a bug
  • Run the backend locally and it works
  • Added migrations if there are any database changes, rebased onto develop if necessary for linear migration history

For maintainers

  • Maintainers can push commits to my branch
  • Maintainers can merge this PR for me

@vercel

vercel Bot commented May 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
couchers Ready Ready Preview May 26, 2026 8:33pm

Request Review

Comment thread app/backend/src/couchers/email/smtp.py Outdated
@tristanlabelle tristanlabelle changed the title Backend/emails: Correct SMTP headers for ics attachments Backend/emails: Support specifyin SMTP headers of attachments May 18, 2026
@tristanlabelle tristanlabelle changed the title Backend/emails: Support specifyin SMTP headers of attachments Backend/emails: Support custom SMTP headers for attachments May 18, 2026
@tristanlabelle
tristanlabelle marked this pull request as ready for review May 18, 2026 06:33
@tristanlabelle
tristanlabelle requested a review from aapeliv as a code owner May 18, 2026 06:33
@tristanlabelle
tristanlabelle requested review from a team and WouldYouKindly May 18, 2026 06:33
aapeliv
aapeliv previously approved these changes May 25, 2026
Comment thread app/backend/proto/internal/jobs.proto Outdated
@tristanlabelle
tristanlabelle force-pushed the backend/bugfix/email-attachments-headers branch from 55102de to 6b483ad Compare May 26, 2026 20:28
@tristanlabelle

Copy link
Copy Markdown
Contributor Author

Rebased to resolve conflicts (adjacent import lines had changed in render_email.py)

@tristanlabelle
tristanlabelle merged commit a0070f7 into develop May 26, 2026
5 checks passed
@tristanlabelle
tristanlabelle deleted the backend/bugfix/email-attachments-headers branch May 26, 2026 21:23
@github-actions github-actions Bot added the release notes: pending Add to stuff that should be included in release notes label May 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📝 Release Notes

This PR should be included in the release notes.

Suggested release note:

Improved calendar email attachments so host request events work more reliably across email and calendar apps
🤖 Bot Debug Information

Model: couchers.openai.gpt-5.4
Decision: include
Reasoning: This is an important user-facing bug fix: it improves .ics calendar attachment compatibility in email clients for host request emails, making calendar events behave correctly when users receive them. While technical, the impact is noticeable to end users who add or remove hosting events from their calendars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: pending Add to stuff that should be included in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants