mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 13:04:38 +03:00
implement accepting dmarc & tls reports for other domains
to accept reports for another domain, first add that domain to the config, leaving all options empty except DMARC/TLSRPT in which you configure a Domain. the suggested DNS DMARC/TLSRPT records will show the email address with configured domain. for DMARC, the dnscheck functionality will verify that the destination domain has opted in to receiving reports. there is a new command-line subcommand "mox dmarc checkreportaddrs" that verifies if dmarc reporting destination addresses have opted in to received reports. this also changes the suggested dns records (in quickstart, and through admin pages and cli subcommand) to take into account whether DMARC and TLSRPT is configured, and with which localpart/domain (previously it always printed records as if reporting was enabled for the domain). and when generating the suggested DNS records, the dmarc.Record and tlsrpt.Record code is used, with proper uri-escaping.
This commit is contained in:
@ -1214,9 +1214,20 @@ func prepareDynamicConfig(ctx context.Context, dynamicPath string, static config
|
||||
// ../rfc/8616:234
|
||||
addErrorf("DMARC localpart %q is an internationalized address, only conventional ascii-only address possible for interopability", lp)
|
||||
}
|
||||
addrdom := domain.Domain
|
||||
if dmarc.Domain != "" {
|
||||
addrdom, err = dns.ParseDomain(dmarc.Domain)
|
||||
if err != nil {
|
||||
addErrorf("DMARC domain %q: %s", dmarc.Domain, err)
|
||||
} else if _, ok := c.Domains[addrdom.Name()]; !ok {
|
||||
addErrorf("unknown domain %q for DMARC address in domain %q", dmarc.Domain, d)
|
||||
}
|
||||
}
|
||||
|
||||
domain.DMARC.ParsedLocalpart = lp
|
||||
domain.DMARC.DNSDomain = addrdom
|
||||
c.Domains[d] = domain
|
||||
addrFull := smtp.NewAddress(lp, domain.Domain).String()
|
||||
addrFull := smtp.NewAddress(lp, addrdom).String()
|
||||
dest := config.Destination{
|
||||
Mailbox: dmarc.Mailbox,
|
||||
DMARCReports: true,
|
||||
@ -1243,9 +1254,20 @@ func prepareDynamicConfig(ctx context.Context, dynamicPath string, static config
|
||||
// to keep this ascii-only addresses.
|
||||
addErrorf("TLSRPT localpart %q is an internationalized address, only conventional ascii-only address allowed for interopability", lp)
|
||||
}
|
||||
addrdom := domain.Domain
|
||||
if tlsrpt.Domain != "" {
|
||||
addrdom, err = dns.ParseDomain(tlsrpt.Domain)
|
||||
if err != nil {
|
||||
addErrorf("TLSRPT domain %q: %s", tlsrpt.Domain, err)
|
||||
} else if _, ok := c.Domains[addrdom.Name()]; !ok {
|
||||
addErrorf("unknown domain %q for TLSRPT address in domain %q", tlsrpt.Domain, d)
|
||||
}
|
||||
}
|
||||
|
||||
domain.TLSRPT.ParsedLocalpart = lp
|
||||
domain.TLSRPT.DNSDomain = addrdom
|
||||
c.Domains[d] = domain
|
||||
addrFull := smtp.NewAddress(lp, domain.Domain).String()
|
||||
addrFull := smtp.NewAddress(lp, addrdom).String()
|
||||
dest := config.Destination{
|
||||
Mailbox: tlsrpt.Mailbox,
|
||||
TLSReports: true,
|
||||
|
Reference in New Issue
Block a user