How to Set Up SPF and DKIM for Mailgun

SPF DKIM Mailgun Email domain authentication

When you first set up Mailgun to send emails, you may find there is a "via mailgun.org", "via mailgun.us", or "via mailgun.info" warning for the email in the recipient's mailbox.

This warning means you haven't authorized Mailgun to deliver emails for you, so the mailbox provider considers that sent from Mailgun instead of your brand.

To authorize Mailgun to send emails for you, you need to set up SPF and DKIM for Mailgun. This is a process also known as email domain authentication.

Setting up SPF and DKIM for Mailgun has 2 benefits:

  • your emails are more likely to reach the inbox;
  • the "via Mailgun" warning is removed, and your emails are perceived as coming from your brand, instead of Mailgun. This boosts user engagement, as the user is more likely to open the email.

How to set up SPF and DKIM for Mailgun:

  1. Set up SPF

    You need to create a new SPF record or update your existing SPF record on your domain:

    • if you have no SPF record on your domain, simply publish the following SPF record on it:

      v=spf1 include:mailgun.org -all
    • if you already have an SPF record, simply insert include:mailgun.org right before the terminating mechanism in that record.

      For example, if your current SPF record looks like this:

      v=spf1 a -all

      update it to:

      v=spf1 a include:mailgun.org -all
  2. Set up DKIM

    Log in to Mailgun using your credentials.

    Navigate to the Domain Verification & DNS section of the domain settings page.

    Publish the following DKIM record for your domain in the DNS:

    Record Type Name Value TTL
    TXT smtp._domainkey.example.com (value from "Enter this value" in the table) Default

    Note: replace the example.com domain in the above record with your own.

Now email domain authentication is set up for Mailgun.

Article précédent Article suivant

 Protect Business Email & Improve Email Deliverability

Get a 14 day trial. No credit card required.

Create Account