(ctx context.Context, hdr textproto.Header)
| 241 | } |
| 242 | |
| 243 | func (s *state) relyOnDMARC(ctx context.Context, hdr textproto.Header) bool { |
| 244 | fromDomain, err := maddydmarc.ExtractFromDomain(hdr) |
| 245 | if err != nil { |
| 246 | s.log.Error("DMARC domains extract", err) |
| 247 | return false |
| 248 | } |
| 249 | |
| 250 | policyDomain, record, err := maddydmarc.FetchRecord(ctx, s.c.resolver, fromDomain) |
| 251 | if err != nil { |
| 252 | s.log.Error("DMARC fetch", err, "from_domain", fromDomain) |
| 253 | return false |
| 254 | } |
| 255 | if record == nil { |
| 256 | return false |
| 257 | } |
| 258 | |
| 259 | policy := record.Policy |
| 260 | // We check for subdomain using non-equality since fromDomain is either the |
| 261 | // subdomain of policyDomain or policyDomain itself (due to the way |
| 262 | // FetchRecord handles it). |
| 263 | if !dns.Equal(policyDomain, fromDomain) && record.SubdomainPolicy != "" { |
| 264 | policy = record.SubdomainPolicy |
| 265 | } |
| 266 | |
| 267 | return policy != dmarc.PolicyNone |
| 268 | } |
| 269 | |
| 270 | func prepareMailFrom(from string) (string, error) { |
| 271 | // INTERNATIONALIZATION: RFC 8616, Section 4 |
no test coverage detected