Configuring Mailgun with a HostGator Domain for Email Delivery

Introduction

To send emails reliably from your CRM, you can integrate a dedicated email delivery service like Mailgun. This guide explains how to configure your Mailgun account with a domain registered through HostGator by updating your domain's DNS settings.

Prerequisites

Before you begin, ensure you have:

  • A Mailgun account.
  • Access to the HostGator cPanel for your domain.
  • Decided whether to use your main domain (e.g., yourdomain.com) or a subdomain (e.g., mail.yourdomain.com) with Mailgun. Using a subdomain is recommended if your main domain already handles email through another service like Google Workspace.

Step 1: Add Your Domain in Mailgun

Log into your Mailgun account. Navigate to the sending settings and select the option to add a new domain. Enter the domain or subdomain you wish to configure. Ensure you select the US region for setup. After adding the domain, Mailgun will display a list of required DNS records. Keep this screen open for reference in the next steps.

Step 2: Access DNS Records in HostGator cPanel

Log into your HostGator cPanel. In the Domains section, locate and click on Zone Editor. Find your domain in the list and click the button to manage its records. This will open the interface where you can add new DNS records.

Step 3: Add the Required DNS Records

You will need to add five specific DNS records from Mailgun into your HostGator Zone Editor. Add them one at a time using the +Add Record button.

First TXT Record (SPF)

  • Type: TXT
  • Name: Enter the host name. For a subdomain like mg.yourdomain.com, enter mg. For your main domain, enter the @ symbol.
  • Record (TXT Value): Paste the SPF value provided by Mailgun, which will look similar to v=spf1 include:mailgun.org ~all.

Second TXT Record (DKIM)

  • Type: TXT
  • Name: Copy the specific host name for the DKIM record from your Mailgun setup screen. Do not include your root domain.
  • Record (TXT Value): Paste the longer, unique DKIM key value provided by Mailgun.

First MX Record

  • Type: MX
  • Name: Enter the same host name you used for the first TXT record (e.g., mg for a subdomain or @ for the main domain).
  • Priority: Set this to 10.
  • Destination: Enter mxa.mailgun.org.

Second MX Record

  • Type: MX
  • Name: Enter the same host name as the first MX record.
  • Priority: Set this to 10.
  • Destination: Enter mxb.mailgun.org.

CNAME Record

  • Type: CNAME
  • Name: Copy the specific host name for the CNAME record from your Mailgun setup screen (e.g., email.mg). Do not include your root domain.
  • Record (Canonical Name): Enter mailgun.org.

Step 4: Verify Setup in Mailgun

After adding all five records in your HostGator Zone Editor, return to the Mailgun domain setup screen. Click the button to verify your DNS settings. DNS changes can take some time to propagate globally. If verification does not succeed immediately, wait a few minutes and try again.

Step 5: Complete CRM Integration

Once Mailgun confirms all DNS records are verified, retrieve your Mailgun API key from your account settings. Enter this API key into the email service settings within your CRM to complete the connection.

Frequently Asked Questions

Should I use my main domain or a subdomain with Mailgun?

If your main domain is already configured for email with another provider (like Google Workspace), you must use a subdomain with Mailgun to prevent mail delivery conflicts. Only use your main domain if it is not currently set up for receiving email elsewhere.

What does "do not include the root domain" mean in the Name field?

In the HostGator Zone Editor, the Name field only requires the specific host or subdomain part. The system automatically appends your root domain. For example, for mg.yourdomain.com, you would simply enter mg.

Will this configuration break my existing Google Workspace email?

No, provided you use a subdomain for Mailgun and do not modify or remove the existing MX records for your main domain that point to Google's servers. Your primary email service will remain unaffected.

How long does DNS propagation take?

DNS updates can take anywhere from a few minutes to 48 hours to fully propagate across the internet. Most changes are visible within an hour.