Skip to content

Fix: Set Message-Id and Date headers on outgoing emails#115

Merged
Wh1isper merged 2 commits intoai-zerolab:mainfrom
frlefebvre:message-id-fix
Feb 14, 2026
Merged

Fix: Set Message-Id and Date headers on outgoing emails#115
Wh1isper merged 2 commits intoai-zerolab:mainfrom
frlefebvre:message-id-fix

Conversation

@frlefebvre
Copy link
Contributor

Problem:
Emails sent were missing Message-Id and Date headers. When using iCloud SMTP (and similar providers), these headers are assigned server-side during delivery, but they don't appear in the copy saved to the IMAP Sent folder. This breaks email threading in clients like Apple Mail, which build the References chain from the Sent folder copy rather than the delivered message.

Fix:
Generate Message-Id (via email.utils.make_msgid) and Date (via email.utils.formatdate) headers on the message object before both sending via SMTP and saving to the Sent folder. This ensures the same values appear in both copies.

Emails sent via the MCP server are missing Message-Id and Date headers.
When using iCloud SMTP (and similar providers), these headers are assigned
server-side during delivery, but they don't appear in the copy saved to
the IMAP Sent folder via APPEND. This breaks email threading in clients
like Apple Mail, which build the References chain from the Sent folder
copy rather than the delivered message.

Generate Message-Id (via email.utils.make_msgid) and Date (via
email.utils.formatdate) headers on the message object before both
sending via SMTP and saving to the Sent folder, so the same values
appear in both copies.
Cover header presence and domain extraction from the sender address,
and verify the same Message-Id and Date appear on both the SMTP-sent
message and the returned object used for IMAP Sent folder saving.
@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Wh1isper Wh1isper merged commit 9a1e992 into ai-zerolab:main Feb 14, 2026
9 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.

2 participants