Authenticating Mailgun Emails with SPF and DKIM
Why are my Mailgun emails going to Spam?
If you have a problem with Mailgun emails going to spam, that is, going to the junk folder of your recipients, then it is very likely an issue with your email authentication. Emails failing authentication, be they failing SPF, failing DKIM, or failing DMARC is common, as SPF, DKIM, and DMARC are often not properly implemented by domain administrators. Often, the main cause of Mailgun emails being blocked is due to the Mailgun emails failing DMARC, which in the case of Mailgun, is usually due to a misconfiguration of SPF and DKIM.
How to stop Mailgun emails going to Junk.
The first step to preventing Mailgun email going to spam is to retrieve a failed message and access its header information. This will allow you to quickly diagnose whether any authentication issues such as DKIM or DMARC are flagging your email as spam, instructing the recipient sender to move it to junk. Simply paste the email headers into our free Stellastra Deliverability Tool, which you can use freely with no log in required. Our deliverability tool should allow you to avoid Mailgun emails from going to spam, or at least rule out authentication as the issue.
How to remove 'via mailgun.com' or 'on behalf of mailgun.com'
Another example of where a Mailgun DKIM misconfiguration is to blame, is if your recipients report seeing the message as 'via mailgun.com' or 'on behalf of mailgun.com' and that the emails typically end up in spam or junk. The Stellastra Email Deliverability tool above will confirm this prognosis, however, you may also wish to configure DKIM for Mailgun by logging in to your Mailgun account to check to see if you have followed the following article to configure your Mailgun dkim setup to authenticate your domain.
How to stop Mailgun Failing DMARC
To ensure that your Mailgun campaigns pass DMARC and get delivered to your prospects, it is important to ensure that DKIM and SPF passes authentication for your domain. A common mistake is to sign an email with Mailgun's own DKIM keys. However, in order for Mailgun's email to pass authentication for your own domain, it is necessary to use your own DKIM keys as per Mailgun's own guide. If you wish to verify the above, paste the message headers for a failed Mailgun message into our Mailgun email testing tool. Furthermore, you should also follow the instructions on how to set up SPF authentication for Mailgun.