Adds an optional log_dns_record configuration key (default 0) to the - #182
Open
pacellig wants to merge 1 commit into
Open
Adds an optional log_dns_record configuration key (default 0) to the#182pacellig wants to merge 1 commit into
0) to the#182pacellig wants to merge 1 commit into
Conversation
SPF, DKIM and DMARC handlers. When enabled, each handler performs one
additional DNS TXT lookup after the authentication check and appends the
raw record content as a comment node to the Authentication-Results entry:
Authentication-Results: mail.example.com;
spf=softfail smtp.mailfrom=sender@example.com
(x-dns-record=v=spf1 redirect=_spf.google.com);
dmarc=fail policy.applied-disposition=none header.from=example.com
(x-dns-record=v=DMARC1; p=reject; rua=mailto:dmarc@example.com)
Comment nodes are permitted by RFC 8601 and are ignored by
standards-compliant downstream parsers and mail clients.
When investigating authentication failures it is useful to see the actual
DNS policy that drove the decision without having to perform a manual DNS
lookup. This is particularly valuable in automated processing pipelines
where the raw record is needed alongside the authentication result.
- The DNS lookup uses the handler's existing get_object('resolver')
mechanism, so it respects any mock resolver configured in tests.
- Failures (NXDOMAIN, timeout, resolver error) are caught with eval
and forwarded to handle_exception — they never affect the
authentication result or cause the milter to tempfail.
- The option defaults to 0 so there is no behaviour change for existing
deployments.
- One extra DNS round-trip per enabled handler per message when the
option is on.
| File | Change |
|---|---|
| lib/Mail/Milter/Authentication/Handler/SPF.pm | log_dns_record option: default_config, lookup block, pod docs |
| lib/Mail/Milter/Authentication/Handler/DKIM.pm | Same |
| lib/Mail/Milter/Authentication/Handler/DMARC.pm | Same |
| share/authentication_milter.json | Add "log_dns_record": 0 to SPF, DKIM, DMARC sections |
| t/04-unit-handler-log-dns-record.t | New — 6 subtests (3 handlers × enabled/disabled) |
pacellig
marked this pull request as ready for review
August 4, 2026 10:51
Author
|
@notbrokenjemma would appreciate a review when you have a moment, thanks! |
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.
SPF, DKIM and DMARC handlers. When enabled, each handler performs one additional DNS TXT lookup after the authentication check and appends the raw record content as a comment node to the Authentication-Results entry:
Comment nodes are permitted by RFC 8601 and are ignored by standards-compliant downstream parsers and mail clients.
When investigating authentication failures it is useful to see the actual DNS policy that drove the decision without having to perform a manual DNS lookup. This is particularly valuable in automated processing pipelines where the raw record is needed alongside the authentication result.