fix(email): set Message-ID header on every outbound message #428

Merged
Claude-Run merged 1 commit from fix/PMS-624-outbound-message-id into main 2026-07-04 04:15:27 +02:00
Member

lettre's MessageBuilder::build auto-inserts Date when missing but never generates a Message-ID unless one is set explicitly. All three SMTP send paths (send_password_reset, send_welcome, send_text) built messages without calling .message_id(...), so outbound mail shipped with no Message-ID header. Google Workspace rejects such messages, bouncing them for at least one recipient.

Route every send through a shared base_builder that sets From, To, and a fresh <uuid@from-domain> Message-ID. The domain is taken from the configured From address (lettre's hostname feature is disabled, so the built-in message_id(None) path would produce @localhost); anchoring to the sending domain keeps the id RFC 5322 valid and deliverable. Date continues to be added automatically by lettre.

Add unit tests asserting the generated Message-ID is unique and anchored to the From domain, and that a message built via base_builder carries both Message-ID and Date headers, so the invariant is enforced mechanically.

#PMS-624

lettre's `MessageBuilder::build` auto-inserts `Date` when missing but never generates a `Message-ID` unless one is set explicitly. All three SMTP send paths (`send_password_reset`, `send_welcome`, `send_text`) built messages without calling `.message_id(...)`, so outbound mail shipped with no `Message-ID` header. Google Workspace rejects such messages, bouncing them for at least one recipient. Route every send through a shared `base_builder` that sets `From`, `To`, and a fresh `<uuid@from-domain>` `Message-ID`. The domain is taken from the configured From address (lettre's `hostname` feature is disabled, so the built-in `message_id(None)` path would produce `@localhost`); anchoring to the sending domain keeps the id RFC 5322 valid and deliverable. `Date` continues to be added automatically by lettre. Add unit tests asserting the generated Message-ID is unique and anchored to the From domain, and that a message built via `base_builder` carries both `Message-ID` and `Date` headers, so the invariant is enforced mechanically. #PMS-624
fix(email): set Message-ID header on every outbound message
All checks were successful
E2E / Playwright against staging (pull_request) Successful in 57s
Check / fmt + clippy + build + tests (pull_request) Successful in 1m58s
Integration / integration tests (pull_request) Successful in 9m18s
Create release / Gate (release-branch merges only) (pull_request) Successful in 1s
Create release / Create release from merged PR (pull_request) Has been skipped
10bfc58e29
lettre's `MessageBuilder::build` auto-inserts `Date` when missing but never generates a `Message-ID` unless one is set explicitly. All three SMTP send paths (`send_password_reset`, `send_welcome`, `send_text`) built messages without calling `.message_id(...)`, so outbound mail shipped with no `Message-ID` header. Google Workspace rejects such messages, bouncing them for at least one recipient.

Route every send through a shared `base_builder` that sets `From`, `To`, and a fresh `<uuid@from-domain>` `Message-ID`. The domain is taken from the configured From address (lettre's `hostname` feature is disabled, so the built-in `message_id(None)` path would produce `@localhost`); anchoring to the sending domain keeps the id RFC 5322 valid and deliverable. `Date` continues to be added automatically by lettre.

Add unit tests asserting the generated Message-ID is unique and anchored to the From domain, and that a message built via `base_builder` carries both `Message-ID` and `Date` headers, so the invariant is enforced mechanically.

#PMS-624
Claude-Run deleted branch fix/PMS-624-outbound-message-id 2026-07-04 04:15:27 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!428
No description provided.