Configuring Mailgun with a Namecheap Domain for CRM Email

Overview

This guide explains how to configure a domain hosted with Namecheap for use with Mailgun, a third-party email service provider. Proper configuration ensures your domain is verified and emails sent through your CRM are delivered reliably.

Prerequisites

Before you begin, ensure you have:

  • A Namecheap account with a registered domain
  • A Mailgun account
  • Access to modify your domain's DNS settings in Namecheap

Step 1: Create and Verify Your Mailgun Account

If you haven't already, sign up for an account at Mailgun.com. After registration, check your email inbox to verify the address you used to sign up.

Step 2: Add a New Domain in Mailgun

Log into your Mailgun account. Navigate to the Sending section and select the option to add a new domain.

Step 3: Choose a Domain Type

You can configure either your main domain (e.g., yourcompany.com) or a subdomain (e.g., mail.yourcompany.com).

  • Main Domain: Use this option if the domain is not currently used with another email service like Google Workspace.
  • Subdomain: This is the recommended option to avoid conflicts with existing email services. You can choose any subdomain name, such as mg.yourcompany.com or email.yourcompany.com.

Select the US region (not EU) when prompted, then confirm to add the domain.

Step 4: Add DNS Records in Namecheap

Log into your Namecheap account. Go to your Domain List and select Manage for the domain you are configuring. Click on Advanced DNS to access the DNS management area.

You will need to add five DNS records: two TXT records, two MX records, and one CNAME record.

First TXT Record

Click Add New Record and select TXT Record.

  • For the Host field:
    • If using a subdomain (e.g., mg.yourcompany.com), enter the subdomain part (e.g., mg).
    • If using the main domain, enter @.
  • For the Value field, copy the first TXT record value provided by Mailgun (it will look similar to v=spf1 include:mailgun.org ~all) and paste it here.
  • Save the record.

Second TXT Record

Add another new TXT record.

  • For the Host field, carefully copy only the initial part of the domain as specified by Mailgun (do not include the main domain). The exact value depends on whether you are using a subdomain or main domain.
  • For the Value field, paste the second, longer TXT record value provided by Mailgun.
  • Save the record.

First MX Record

Important: If you are configuring your main domain and it is currently used with Google Workspace or another email provider, switching to Custom MX in Namecheap will disrupt incoming mail. It is strongly advised to use a subdomain for Mailgun to avoid this. If you must use the main domain, you will need to re-add the existing provider's MX records (e.g., Google's five MX records) alongside Mailgun's.

In the Mail Settings section of Namecheap's Advanced DNS, change the dropdown to Custom MX.

Click Add New Record to add an MX record.

  • For the Host field:
    • If using a subdomain, enter the subdomain part (e.g., mg).
    • If using the main domain, enter @.
  • For the Value field, enter: mxa.mailgun.org
  • Set the Priority to 10.
  • Save the record.

Second MX Record

Add another new MX record.

  • For the Host field, use the same value as the first MX record (subdomain part or @).
  • For the Value field, enter: mxb.mailgun.org
  • Set the Priority to 10.
  • Save the record.

CNAME Record

Add a new CNAME record.

  • For the Host field:
    • If using a subdomain (e.g., mg.yourcompany.com), the host is typically email.[subdomain], such as email.mg.
    • If using the main domain, the host is typically email.
  • For the Value field, enter: mailgun.org
  • Save the record.

Step 5: Verify DNS Settings

After adding all five records in Namecheap, return to Mailgun and click the button to Verify DNS Settings. DNS changes can take some time to propagate. If some records do not verify immediately, wait a while and try again.

Step 6: Retrieve API Key and Test

Once all DNS records are verified in Mailgun, locate your API key within the Mailgun dashboard. You will need this key to configure Mailgun in your CRM's email settings. Finally, send a test email to confirm everything is working correctly.