SPF, DKIM and DMARC for a small app, in plain words

If your app sends password resets or receipts, mailbox providers decide whether to trust each message. SPF, DKIM and DMARC are the three DNS checks they use. This guide explains each in plain words, in the order to set them up.

What each check does

Think of the three as a chain. Google's Workspace help describes all three. SPF is a DNS record that lists the servers allowed to send email for your domain. DKIM signs each message with a private key, and the matching public key sits in a DNS record so receivers can check the signature. DMARC tells receivers what to do with mail from your domain that fails the SPF or DKIM check.

Why a small app should care

Gmail's sender guidelines set a minimum for everyone and more for large senders. All senders need SPF or DKIM, TLS, and a spam rate below 0.3 percent. Senders of more than 5,000 messages a day to Gmail need SPF and DKIM, and DMARC with at least a policy of none. Google also says the keys for DKIM must be at least 1024 bits and recommends 2048. For marketing or subscribed messages, Google also asks for one-click unsubscribe headers and a clearly visible unsubscribe link in the body. For direct mail from bulk senders, the From domain must align with the SPF or DKIM domain. A small app may be below those volumes, but the same checks help your messages reach the inbox, and they are cheap to set up while the app is young. They also protect your domain: without them, anyone can try to send mail that claims to come from you.

Step 1: SPF

SPF is a TXT record on your sending domain. According to Google, it starts with v=spf1, then has an include entry for each service that sends mail for you, and ends with a tag such as ~all. A domain needs one SPF record, and a record can have up to 10 include entries, so add your email sending service to your existing record instead of making a second one. Remove senders you no longer use. SPF can take up to 48 hours to start working. Each subdomain that sends mail needs its own record, so if your app sends from a subdomain, set the record there.

Step 2: DKIM

Your sending service creates a key pair for your domain and gives you the public half to publish in DNS as a TXT record, under a name made of a selector and the text _domainkey. Google recommends a 2048-bit key if your DNS provider supports it, and 1024-bit otherwise. DKIM can also take up to 48 hours to start working. If your domain already has a DKIM key for another service, choose a different selector so the two do not collide. Keep the private key private: only the public half goes in DNS.

Step 3: DMARC, and checking it works

Google says to turn on SPF or DKIM first and wait 48 hours before enabling DMARC. Start with the policy set to none, which delivers the mail and logs it in reports. This is the safe first step: it changes nothing for your readers while you learn what is sending as your domain. Use the rua tag to send the daily summary reports to a dedicated mailbox, because the volume can be high. If that mailbox is on a different domain, Google says you must add a DNS record there as well. When the reports show that your legitimate mail passes, move to quarantine, then reject, raising the percentage in steps.

  • Send a test message to a mailbox you control and open the full message headers, which most mail apps can show.
  • Look for the authentication results and confirm SPF and DKIM pass.
  • Make sure the From domain on the message is the domain you set up.
  • Check again after you add any new service that sends mail for the domain.
  • Do not tighten DMARC until the reports show all your real senders passing.
  • Keep to one SPF record per domain, and edit it when you add a sender.
  • Allow up to 48 hours for new SPF and DKIM records to start working before you judge the result.

Where OutboxPier fits

OutboxPier is coming soon and is meant to automate the sending side: you add your domain, it gives you the SPF record to add and a DKIM key made for that domain, then your app sends through an API or SMTP and you can read the delivery log. We have not set a launch date, and the steps above work with any sending service.

Sources

Coming soon: OutboxPier

Send-only email for your app at one flat price. OutboxPier lets a developer add a sending domain and send email from an app through a web API or SMTP. Mail is signed with DKIM, queued, logged for each recipient, and bounces and complaints stop later sends. It is for small apps that want simple email sending without surprises.

About OutboxPierPrice comparison

Get OutboxPier first

Join the list and get 25% off your first purchase when it goes on sale. We email you a discount code on launch day. One code per person, for new customers.

One email when it launches (plus the discount code). No other mail, and you can say stop at any time. See our privacy policy.

An unhandled error has occurred. 🗙