In this article I’d like to explain the role of MX records in DNS zone.
In common words it is a combination of digits and letters that determines the mail delivery route for the definite domain.
It consists of the IP address and the record priority.
Priority is a common number that determines the order of the servers in the delivery chain, if you have multiple mail servers. Prioritized server has the lowest priority value.
Let us consider that there are 2 mail servers. First server has priority set to 10, the second server has priority set to 20. Emails will be delivered to the server with priority set to 10. The server with 20 priority will be used if email delivery fails to the first server.
If there is no MX record, than emails will be delivered according to the ‘A’ record.
How to use the benefits?
Example 1: Let’s assume that you have a website hosted at GoDaddy shared account. Also you have business account at Gmail with list of mailboxes. In order to make the mail to be delivered to Gmail you need to create proper MX records in the DNS zone of your domain and point them to the Google mail servers.
The is an awesome work arround with MX records when you need to migrate your mailboxes from one server to another. For example you can have a mail server with the multiple hundreds of mailboxes. You’d like to move all mailboxes to the upgraded server with the most recent mail software. You’ll have to update the DNS records during this process and there is a big chance that some portion of emails will be lost during the propagation of the new DNS records.
In order to avoid this you can add another MX record into the DNS zone and point it to the ip address of the new server. The priority value should be higher to make this server slave.
After this existing server will be considered as master and the new server will be considered as slave. When the propagation of the new MX record is complete you can sync emails, stop mail daemon on the existing server and switch DNS records. All emails will be delivered to the new server.
The following tool can be used to monitor the DNS propagation: https://www.whatsmydns.net/
MX records for Gmail: https://support.google.com/a/answer/174125?hl=en