Mail Exchanger Records
Mail Exchanger or MX records are part of the DNS information for a domain. An MX record has a preference. Preferences are an unsigned 16bit number and hence, range from 0 to 65535. MX records with a lower preference are preferred. MX records with equal preference are valid and are treated equally. As an example the MX records for the domain webhosting.uk.com are;
The DNS contains the MX entry as
webhosting.uk.com 14400 IN MX 10 mail.webhosting.uk.com
webhosting.uk.com 14400 IN MX 20 mail2.webhosting.uk.com
When a foreign mail server wants to send a message to an address at webhosting.uk.com the foreign server will first attempt to deliver the message to mail.webhosting.uk.com. If this fails then the foreign mail server will attempt to deliver the message to mail2.webhosting.uk.com. If this fails then the foreign mail server should wait and then retry the process starting with mail.webhosting.uk.com. If the mail is successfully delivered to mail2.webhosting.uk.com then it is up to that server to deliver the mail but typically it will deliver the message to mail.webhosting.uk.com. In this way mail for a domain passes through the lowest preference Mail Exchanger.