Receiving Email at Mailgun for your Domain

  • Setup Mail Exchanger (MX) Records in DNS

    The last step in our guide is going to be to configure Mailgun to forward email it receives for your domain over to an existing email address (i.e. a Gmail, Yahoo, Hotmail, AOL, whatever address - just an existing email address that you already receive email at).
  • This guide does not cover setting up your own POP3 / IMAP server for receiving email on your server - if you need to set that up you should be able to find plenty of guides using Google.
  • Our first step is to setup Mail Exchanger records - commonly known as "MX Records":

    An MX record tells a sending email server that Mailgun is accepting email for your domain so it gets routed appropriately.

    To setup our MX records, make sure you are logged into DigitalOcean, and go to the DNS records listing for your new domain (DNS -> click on the magnifying glass to the right of your domain).

    Next, click on the big blue "Add Record" button in the upper right corner, and choose "MX" as the record type:
  • You need to do this 2 TIMES - once for "mxa" and once for "mxb"!
  • For the hostname you want to enter: - again don't forget that trailing period, as it is required.

    For the Priority, set it to "10". Then click the green Create button to create the record.

    Now we have to create another record exactly the same as this one, but this time it is for the "mxb" host:

    Set the priority to 10 as well and create that record.

    That's it - your MX records are now setup for your domain.
  • Setting up email routing in Mailgun

    Our next step is to setup "routing" of incoming email and forwarding it over to an existing email address you are already using.

    This is one of the coolest, most powerful features that Mailgun offers, and is what makes their system really awesome. You can "route" email to not only other email address, but you can have email (already parsed) POSTED to a URL. This is how Jamroom's Support Center works!

    So log back into your Mailgun Control Panel and click on the "Routes" tab:
  • Once the Routes page loads, click on the "Create Route" button:
  • You will then see the "Create new Route" screen:
  • To setup our new "route", do the following:

    - in the Priority field, set it to "1"

    - in the Filter Expression field, start typing "match_recipient" and you will see it sees what you are trying to type and has a drop down match - click on it to add the new route rule. Inside the quotes, you want to enter the email address you want to receive email at - i.e. "" - of course change "" to whatever. For me it is "".

    - next, in the Actions field start typing the word "forward" and you will see it once again sees what you are typing and suggests the "forward()" action - select that with your mouse, and in between the quotes enter your existing email address you are already receiving email at.

    - lastly, give it a description if you would like.

    Then click on the black "Save" button at the bottom and your new route will be created. Now when someone sends email to "" it will be forwarded over to your existing email.

    You are all set! You can enter as many routes as you want for different email address (maybe you want to have a "support" email address, or a "sales" email address, etc.).
27 Nov 2013 07:30:22AM @paul:
You can use match_recipient(".*") as the Filter Expression to 'catch all'.
27 Nov 2013 12:26:08PM @silver-kamel:
Great job with this guide Brian. I may actually try it. Don't be surprised if I give you a holler tho'.
01 Feb 2014 03:49:29PM @ilovehousemusic:
This is where I errored from a previous install. So just want to share this info for anyone following this guide. The next step is to xfer the files to your server.

I used Filezilla, in SFTP session, Binary Mode, and you're going to want to make sure you log in as the web user created at initial setup (not the root user), else you'll have file/dir permissions issues. *thumbsup*

05 May 2015 07:25:30PM @new:
...but you can have email (already parsed) POSTED to a URL. This is how Jamroom's Support Center works!

How to do that? "Post the email received to a URL"

06 May 2015 12:03:03AM @michael:
hi @new,
You don't need to do anything, that's all done by the modules, so as long as mailgun is setup, the modules will be able to do what they need to do.

23 Sep 2016 11:05:51PM @basil-jo:
Hi, I tried the above but no hope, Mails are not getting delivered to the forward list in the action section of Routes. My need is only to receive mails via mailgun. The MX record and DNS check all are done. Can some one help?!!