Add RFC 5322 compliant Message-ID header to email notifications#1557
Merged
crazy-max merged 1 commit intocrazy-max:masterfrom Dec 22, 2025
Merged
Conversation
crazy-max
requested changes
Dec 19, 2025
Owner
crazy-max
left a comment
There was a problem hiding this comment.
Can you squash your commits please?
Otherwise LGTM thanks
Implements unique Message-ID generation for email notifications to enhance email threading, tracking, and spam filter compatibility. Features: - Generates RFC 5322 compliant Message-ID headers - Uses nanosecond timestamps for high-resolution uniqueness - Includes 64 bits of cryptographically secure random data - Format: <timestamp.randomhex@domain> - Domain derived from LocalName config, falling back to Host Tests: - Validates RFC 5322 format compliance - Ensures uniqueness across 1,000 iterations - Verifies correct domain usage and structure
8deffe2 to
b44181f
Compare
crazy-max
approved these changes
Dec 22, 2025
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.
Summary
This PR implements automatic generation of RFC 5322 compliant Message-ID headers for all email notifications sent by diun.
Currently, diun email notifications do not include a Message-ID header, which can cause issues with:
Changes
New function
generateMessageID()ininternal/notif/mail/client.go:<timestamp.randomhex@domain>LocalNameconfig if set, otherwise falls back toHostIntegration in
Send()method:mailMessage.SetHeader("Message-ID", messageID)Comprehensive unit tests in
internal/notif/mail/client_test.go:TestGenerateMessageID: Validates format with LocalName and Host fallbackTestGenerateMessageID_Uniqueness: Verifies uniqueness across 1000 iterationsTestGenerateMessageID_Format: Validates RFC 5322 format complianceBenefits
✅ Improves email threading and tracking in mail clients
✅ Enhances spam filter compatibility
✅ Ensures RFC 5322 compliance for all outgoing notifications
✅ Each message gets a globally unique identifier
Testing
All tests pass successfully:
Tested with:
docker buildx bake testImplementation Details
The Message-ID generation follows RFC 5322 best practices:
<local-part@domain>Example generated Message-ID: