Configuring Mailgun with a SiteGround Domain

Introduction

This guide explains how to configure Mailgun for email sending with a domain hosted on SiteGround. You will learn how to sign up for Mailgun, add your domain, and set up the required DNS records in SiteGround's DNS Zone Editor. The process involves creating two TXT records, two MX records, and one CNAME record.

What You'll Need

  • A SiteGround account with domain hosting
  • A Mailgun account
  • Access to your domain's DNS settings

Step 1: Sign Up for Mailgun and Add Your Domain

Begin by creating an account at Mailgun.com. Verify your email address through the confirmation message sent to your inbox. Once logged in, navigate to the Sending section and select Add New Domain.

Choose whether to use your main domain (e.g., companyname.com) or a subdomain (e.g., mg.companyname.com). If you already use Google Workspace or another email service on your main domain, it is recommended to use a subdomain for Mailgun to avoid conflicts. Select the US region during setup, then click Add Domain.

Step 2: Access DNS Records in SiteGround

Log in to your SiteGround account. Go to Site Tools, then Domain, and select DNS Zone Editor. This is where you will add all the necessary DNS records.

Step 3: Add the First TXT Record (SPF)

In the DNS Zone Editor, click the TXT tab. For the Name field, enter the host name without the root domain. If using a subdomain like mg.companyname.com, enter mg. For the main domain, use @ or leave it empty. In the Value field, paste v=spf1 include:mailgun.org ~all. Click Create.

Step 4: Add the Second TXT Record (DKIM)

Add another TXT record. The Name for this record is specific to your Mailgun setup. Copy the host name portion from the value provided by Mailgun, excluding the root domain. For example, if Mailgun shows mx._domainkey.helpdesk, enter mx._domainkey.helpdesk. Paste the full DKIM value from Mailgun into the Value field. Click Create.

Step 5: Add the First MX Record

Click the MX tab and choose Add your own MX records. For Name, enter the host name (e.g., mg for mg.companyname.com, or @ for the main domain). Set Priority to 10. In the Destination field, enter mxa.mailgun.org. Click Create.

Step 6: Add the Second MX Record

Add another MX record with the same Name and Priority (10). For Destination, enter mxb.mailgun.org. Click Create.

Step 7: Add the CNAME Record

Switch to the CNAME tab. For Name, enter the host name provided by Mailgun, such as email.mg for mg.companyname.com or email for the main domain. In the Resolves to field, enter mailgun.org. Click Create.

Step 8: Verify DNS and Complete Setup

Return to Mailgun and click Verify DNS Settings. If any records are not immediately verified, wait a few minutes and try again, as DNS changes may take time to propagate. Once all records show as verified, you can use your Mailgun API key in your email service settings.

Frequently Asked Questions

Where is the DNS Zone Editor in SiteGround?

After logging in, go to Site Tools → Domain → DNS Zone Editor.

What if I don't see the option to add my own MX records?

Ensure you are on the correct domain and that email hosting is not managed by another provider in your SiteGround plan.

Should I use @ or leave the Name field empty for the main domain?

Both are acceptable in SiteGround's DNS Zone Editor; use whichever the system accepts without error.

Will this affect my existing Google Workspace email?

No, if you use a subdomain for Mailgun and do not modify the main domain's MX records for Google Workspace.

How long does DNS propagation take?

It is usually quick but can take up to a few hours. If verification fails, wait and try again.