Mailgun Setup

Mailgun is a transactional email API service that enables you to send emails from your website or application. This guide will walk you through setting up Mailgun with your SendGrid account.


Following our previous guide, you should have a functioning domain, such as However, we still need to verify it with Mailgun.

Create a Mailgun Account

If you don't already have a Mailgun account, you can sign up for one here.

Add and Verify Your Domain

After creating your account, you'll need to add and verify your domain. To do this, go to the Mailgun Domains page and click the "Add New Domain" button.

  • Navigate to your Namecheap domain dashboard and select the "Manage" button next to the domain you wish to use with Mailgun.
  • Proceed to the "Advanced DNS" tab.
  • Click ADD NEW RECORD and choose TXT Record from the dropdown menu.
  • Enter a new TXT record with the following details:
    • Host: Use @. Do not use your domain name. Despite what Mailgun's official documentation suggests, using your domain name does not work and has led to much confusion and lost time in my experience.
    • Value: Input the value provided by Mailgun, typically formatted as v=spf1 ~all.


  • Host: Enter k1._domainkey. Do not include your domain name. Again, contrary to Mailgun's official guidance, including your domain name is incorrect and misleading.
    • Value: Use the value given by Mailgun, which looks something like k=rsa; p=*****.

Next, navigate to the top of the page and click on the Verify DNS settings button to initiate the verification of your DNS records. This verification may take a few minutes. Upon successful verification, a green checkmark will appear next to your domain.

Note: Additional records such as MX and CNAME are optional and not required.

Was this page helpful?