fix(email): set Message-ID header on every outbound message #428
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-624-outbound-message-id"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
lettre's
MessageBuilder::buildauto-insertsDatewhen missing but never generates aMessage-IDunless 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 noMessage-IDheader. Google Workspace rejects such messages, bouncing them for at least one recipient.Route every send through a shared
base_builderthat setsFrom,To, and a fresh<uuid@from-domain>Message-ID. The domain is taken from the configured From address (lettre'shostnamefeature is disabled, so the built-inmessage_id(None)path would produce@localhost); anchoring to the sending domain keeps the id RFC 5322 valid and deliverable.Datecontinues 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_buildercarries bothMessage-IDandDateheaders, so the invariant is enforced mechanically.#PMS-624