Create a Mail Exchange (MX) record

Most people use email with their domains. To use email, we need a Mail Exchange (MX) record so any domain email is sent to the right place (whether that is a mail server on the slice or an external mail provider).

Let's set that up now.


Simple

The example in this article is a very simple one. I will do a separate article on setting up MX records for Google Apps.

The procedure shown below uses a subdomain called 'mail' and the MX record points to that subdomain.

If you use an external mail agency (such as fusemail or fastmail), then leave out the A-record creation and point the MX record as directed by your provider.

DNS Panel

So, log into the SliceManager at https://manage.slicehost.com and navigate to the DNS tab:

Now click on the 'records' link next to your domain.

If you haven't created a zone for your domain, then refer to this article.

Base Records

You should already have the base records shown here:

Click on the 'new record' link.

A Record

Firstly we need to create a subdomain A Record called 'mail'. The MX record will be directed there.

Again, if you are using an external mail agency, then skip this step. This is only for those who plan on running a mail server on their Slice.

In the fields I entered:

Name: mail

Data: 208.75.84.20

Done. The subdomain record is now complete.

MX Record

Next we need to set an MX Record. Again, click 'new record' and select MX Record from the 'type' drop down box:

In the fields I entered:

Name: mynewdomain.com. (Note the trailing period '.')

Data: mail.mynewdomain.com. (Note the trailing period '.')

Auxiliary Info: 0

Unless you have specific requirements to change the Auxiliary Info, leave it at 0.

If you use an external mail agency, they may suggest other values, in which case, follow their advice.

Dig

Cool. Now we only need to wait for the DNS records to propagate.

However, it would be nice to check the records are correct and we haven't made a typo somewhere.

No problem, we can use the 'dig' command (see the introduction to dig article for more info),

So a simple query of the DNS servers for our MX record would be:

dig @dns1.stabletransit.com mynewdomain.com MX

The 'question' and 'answer' part of the output is as follows:

;; QUESTION SECTION:
;mynewdomain.com.               IN      MX

;; ANSWER SECTION:
mynewdomain.com.        86400   IN      MX      0 mail.mynewdomain.com.

Nice. All the values are as expected.

Summary

We've gone into some detail here but setting MX records for your domain is nice and straight forward using the SliceManager.

Once you have set a record, it is always a good idea to check the values with a simple 'dig' command.

PickledOnion.

Article Comments:

Stephen commented Thu Jan 10 17:39:06 UTC 2008:

I can't seem to get my email hosted by godaddy to work. I was pointed in the direction of this article and was wondering if you could clarify what I need my settings to be in my MX records to make this work!?


When setting up an email account, you may receive the "pending setup: validating MX record" while the system verifies your email account is using the correct MX records. If the MX records are correct, the message disappears. If the message remains, the MX records you specified in your hosting provider or domain name system manager may be incorrect. Your hosting provider is where your domain is hosted; your domain name system manager is a third-party domain manager where you might manage your domain settings, such as your DNS servers or MX records.

If the MX records are incorrect, you can add the correct MX records in your hosting provider or third-party domain name system manager. To Change the MX Record

  1. Log on to your hosting provider or third-party domain name system manager.
  2. Change your MX records to: * MX 0 - smtp.secureserver.net * MX 10 - mailstore1.secureserver.net

comb commented Thu Jan 31 03:17:36 UTC 2008:

http://www.destr0yr.com/article.php/GmailandsSMTP

I was a bit lost on getting my system emails (cron, php generated, etc) off the box if they were addressed to the same domain. Mail to/from other domains were fine.

Anyway, EpochWolf in IRC showed me this nice easy solution: ssmtp. Perhaps a mention in your googleapps and mail related articles.

For us noobies :)

Jeff commented Sat Feb 23 02:56:39 UTC 2008:

Hi. The first bit of advice is exactly what GoDaddy told me today 2/22/2008....but for the life of me, I can't understand where, here at SliceHost, you find the fields * MX 0 and MX 10. Can I buy a clue from someone?

Michael commented Sun Feb 24 20:40:36 UTC 2008:

I too, struggled for about half an hour before I finally got mail services working with my email at another provider. The 10, 0, etc. are just priority numbers. Those numbers go in the Extra/Auxiliary data field. One problem I had, was getting the IP address right. While A and CNAME just take straight IP addresses in form of "192.168.0.1", MX records require a period at the end of the IP address as "192.168.0.1." otherwise it gets expanded on as 192.168.0.1.yourdomain.com, which obviously isn't correct.

Michael commented Sun Feb 24 20:45:06 UTC 2008:

Also, I'm not 100% sure, I believe the "" is equivalent to "yourdomain.com." (with ending period) in the first field for slicehost's interface. Some sites use "none" or "@" while others seem to use "" to indicate, there's no leading value pre-pended to your domain name.

Stéphane Bortzmeyer commented Tue Feb 26 13:51:19 UTC 2008:

No, Michael, do not put an IP address in the right-hand side of a MX record. It is not allowed by the standard and it will break with some software.

Use a host name on the right hand side.

Prime commented Tue Oct 07 13:03:12 UTC 2008:

Hi,

I have just created my mail server, first time at doing anything like this and you articles have been superb, really are some of the best however, i'm still having problems :( I think I have everything setup correctly, i can send emails from my box and I have created a database with my users etc etc... but when i try to login using "evolution" on my laptop I can "Err - Login failed" and i'm not sure how best to debug this issue. Can you give me any pointers?

Thanks for all your help.

Cheers, Prime...

Juan Carlos Reyes commented Wed Nov 19 20:53:23 UTC 2008:

I just spent a few minutes trying to figure out how to add google MX records to my dns. The problem was that in my previous DNS software (bind) I never had a field "name" so had to try a few things before figuring out, that this field is supposed to be the domain name itself that is being configured. I had mistakenly used the same address as the mail server as name..

Stéphane Bortzmeyer commented Sun Dec 14 17:03:57 UTC 2008:

And, to test it, use the email auto-responders:

  • echo@generic-nic.net
  • echo@nic.fr
  • Echo@TU-Berlin.DE
  • echo@tu-chemnitz.de
  • echo@ouain.com
  • repondsmoi@crdp.ac-versailles.fr
  • echo@cnam.fr
  • ping@stamper.itconsult.co.uk
  • ping@oleane.net
  • check-auth@verifier.port25.com

mark commented Mon Mar 02 06:28:17 UTC 2009:

OK - for godaddy:

if you do not have any mx records listed under DNS/Records, add a record.

put "smtp.secureserver.net." in the data field put "0" in the auxiliary field to make it the mx0 record.

(make sure you put a "." at the end of the entry in the "data" field)

Then, save. create a new record

put "mailstore1.secureserver.net." in the data field. put "10" in the auxiliary field to make it the mx0 record.

(make sure you put a "." at the end of the entry in the "data" field)

Go back to Godaddy and redo the email forwarding/setup - when you click OK it will find the new mx records (after a few minutes or so).

Danny commented Thu Oct 15 20:34:26 UTC 2009:

Thanks Mark. That worked.

I made two MX records at my Slicehost account:

Type: MX Name: idtheftawareness.com. Data: mailstore1.secureserver.net. Auxillary Info: 10 TTL: 86400

============================ Type: MX Name: idtheftawareness.com. Data: smtp.secureserver.net. Auxillary Info: 0 TTL: 86400

gavin commented Tue Mar 16 02:18:46 UTC 2010:

What are other people using for a pop3 server? It looks like Dovecot may be the simplest from my quick research.

Wes commented Fri Mar 18 16:53:16 UTC 2011:

We have in house email and i was having some issues getting the email to work properly, i was a bit confused about mail.mydomain.com, and if i needed to create a subdomain or if putting mail.mydomain.com in the a record was good enough. And i had also missed changning the mx record to mail.mydomain.com. Even thought i dont use slicehost this article helped me out, thanks alot

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)