gs.dmarc API Reference¶
Currently only querying the DMARC receiver policy is supported.
A DMARC receiver policy is published in a DNS
TXT record, in
a domain that starts with
_dmarc. It is possible to use the
host program to look up a DMARC record.
$ host -t TXT _dmarc.yahoo.com _dmarc.yahoo.com descriptive text "v=DMARC1\; p=reject\; sp=none\; pct=100\; rua=mailto:email@example.com, mailto:firstname.lastname@example.org\;"
Get the DMARC receiver policy for a host.
Parameters: host (str) – The host to lookup. Returns: The DMARC reciever policy for the host. Return type: A member of the
receiver_policy()function looks up the DMARC reciever polciy for
host. If the host does not have a pubished policy the organizational domain is determined. The DMARC policy for the organizational domain is queried, and the subdomain policy is reuturned (if specified) or the overall policy for the domain is returned. Internally the
gs.dmarc.lookup.lookup_receiver_policy()is used to perform the query.
An enumeration of the different receiver policies in DMARC.
noDmarc= <ReceiverPolicy.noDmarc: 0>¶
No published DMARC receiver-policy could be found. Often interpreted the same way as
none= <ReceiverPolicy.none: 1>¶
The published policy is
none. Recieving parties are supposed to skip the verification of the DMARC signature.
quarantine= <ReceiverPolicy.quarantine: 2>¶
Generally causes the message to be marked as spam if verification fails.
reject= <ReceiverPolicy.reject: 3>¶
Causes the system that is receiving the message to reject the message if the verification fails.
Get the host from an email address, and get the receiver policy.
addr = email.utils.parseaddr('email@example.com') host = addr.split('@') policy = receiver_policy(host) if (policy in (ReceiverPolicy.quarintine, ReceiverPolicy.reject)): # Rewrite the From header
Lookup the reciever policy for a host. Returns a ReceiverPolicy.
The DMARC receiver policy for the host. If there is no published policy then
A member of the