Fix: Set Message-Id and Date headers on outgoing emails#115
Merged
Wh1isper merged 2 commits intoai-zerolab:mainfrom Feb 14, 2026
Merged
Fix: Set Message-Id and Date headers on outgoing emails#115Wh1isper merged 2 commits intoai-zerolab:mainfrom
Wh1isper merged 2 commits intoai-zerolab:mainfrom
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.