Module: MailAuth::Dmarc::Alignment

Defined in:
lib/mailauth/dmarc/alignment.rb

Class Method Summary collapse

Class Method Details

.aligned?(from, candidate, strict:) ⇒ Boolean

Strict and relaxed are separate rules, not a fallback pair — falling back to relaxed after a strict miss would make adkim=s/aspf=s decorative.

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mailauth/dmarc/alignment.rb', line 13

def aligned?(from, candidate, strict:)
  from, candidate = normalize(from), normalize(candidate)

  if from.empty? || candidate.empty?
    false
  elsif strict
    from == candidate
  else
    OrganizationalDomain.of(from) == OrganizationalDomain.of(candidate)
  end
end