How to Set Up SPF for Mailgun

Authorize Mailgun to send transactional email on behalf of your domain by adding the correct SPF include.

Quick Answer — The Record You Need

Record Type

TXT

Host / Name

@

Value
v=spf1 include:mailgun.org ~all

Add include:mailgun.org to your existing SPF record.

Step-by-Step Setup

1

Log in to Mailgun

Go to app.mailgun.com and sign in.

2

Add your domain

Navigate to Sending > Domains > Add New Domain. Enter your domain (or a subdomain like mg.yourdomain.com).

3

Get DNS records

Mailgun will display the DNS records you need. The SPF record uses include:mailgun.org.

4

Add the SPF record to your DNS

Add include:mailgun.org to your existing SPF record, or create a new one.

v=spf1 include:mailgun.org ~all
5

Verify in Mailgun

Click "Verify DNS Settings" in Mailgun. It will check all required records.

Before & After

Before
v=spf1 include:_spf.google.com ~all
After
v=spf1 include:_spf.google.com include:mailgun.org ~all

Common Gotchas

  • Mailgun recommends using a subdomain (e.g., mg.yourdomain.com) for sending, which keeps your root domain SPF record clean.
  • The include is mailgun.org, not mailgun.com. Using the wrong domain will not authorize Mailgun servers.
  • If you use a subdomain for Mailgun, the SPF record goes on that subdomain, not your root domain.

Verify Your Setup

After adding your DNS records, use our free SPF checker to verify everything is configured correctly. DNS changes typically propagate within minutes, but can take up to 48 hours.

Frequently Asked Questions

What SPF record do I need for Mailgun?

Add include:mailgun.org to your SPF record. If you send from a subdomain like mg.yourdomain.com, add the SPF record to that subdomain.

Should I use a subdomain with Mailgun?

Yes. Mailgun recommends using a subdomain (e.g., mg.yourdomain.com) to isolate transactional email reputation from your root domain.

Can I use Mailgun and Google Workspace on the same domain?

Yes. Use a subdomain for Mailgun (e.g., mg.yourdomain.com with its own SPF) and keep your root domain SPF for Google Workspace.

Related Guides