Using the Sender Policy Framework

SPF is an authentication standard used to link a domain name and an email address. it allows email clients to verify that incoming email from a domain comes from a host authorized by the administrator of this domain.

In this tutorial, we will set up SPF for the domain by:

  • Adding DNS TXT records for SPF.
  • Add filtering for incoming and outgoing emails using SPF.

Feel free to replace by your own domain.

Add a DNS TXT record for SPF

A new DNS record is added into the DNS zone. It declares that only the server specified in the MX record is allowed to send messages on behalf of the domain.          TXT "v=spf1 +mx -all"

A TXT record with SPF specifications for the `` domain

TODO: add commands

Filtering with SPF

For incoming messages, SPF is configured to check that the sending host is authorized to use the domain according to published SPF policy. Rules are executed at the mail stage.

Edit the /etc/vsmtp/filter.vsl script and add the following rule.

  mail: [
    rule "check spf" || spf::check(),

Preventing spams using SPF

See the spf::check reference for more details.

To check if DKIM is working correctly, check out this site.