To configure your domain for sending emails through Mailgun, it has to be verified by setting up the SPF and DKIM records to your domain provider’s DNS management section.
The DKIM or Domain Keys Identified Mail is an encryption authentication method that is used to ensure that the email is originated from an authorized system and it prevents spammers from stealing the identity of legitimate entities. Whereas SPF or Sender Policy Framework is used to improve email reliability and prevent spoofing.
The SPF and DKIM DNS records allow Mailgun to deliver email for the domain.
How to Configure Your Domain with Mailgun SPF and DKIM Records
Step 1: Find the SPF and DKIM records on Mailgun Account
Once you have added your domain to your Mailgun account, you’ll find the SPF and DKIM DNS records when you click on your added domain under the Domains tab in the Mailgun control panel. The two TXT records for SPF and DKIM are listed under the Sending section.
Step 2: Add the SPF and DKIM as TXT Record
The next step is to go to your domain provider dashboard and find the DNS Management section. There you will need to select record type TXT from the list to add SPF and DKIM records.
For SPF TXT record under Name/Host, type: @
and for Value, put: v=spf1 include:mailgun.org ~all
For DKIM TXT record under Name/Host use:<prefix>._domainkey
For Value use: copy/paste the DKIM from the Mailgun control panel as shown in Step 1.
Step 3: Check the SPF and DKIM using Online Tool
Once the SPF and DKIM TXT records for Mailgun are added at the domain registrar DNS, propagation will take some time.
To check whether SPF and DKIM records have been set correctly at the domain provider and propagated fully, any records checker such as the mail tester’s tool can be used.