How do MX records work?
MX records are used in conjunction with A records, which are most commonly used to map a fully qualified domain name (FQDN) to an IPv4 address and to translate domain names to IP addresses.
In the case of MX records, the A record points to the mail server(s), and when another mail server wishes to communicate with your mail server, it looks for an MX record. The MX record must point to the A record, which then points to the IP address of the mail server.
When there’s no MX record for the domain, the mail for that domain will generally be attempted to be delivered to the A record that matches. For example, if you were trying to send an email to digicert.com but there were no MX records, the mail would then attempt to deliver to digicert.com’s root record.
MX record failover
MX records don’t support DNS failover, but they have their own built-in failover service. When creating an MX record, you’re given the option to set an MX level for the record, which determines the order in which the mail will be attempted to be delivered—in other words, which mail server the mail should attempt to go to. The mail server with the lowest MX level will be the first attempted for email delivery. If the mail server is down at the lowest level, the next level will be attempted, and so on.
If the email is delivered to a backup mail server with levels 20 or 30, the level 10 mail server will again be the first to be tried when it comes back online.
If multiple MX records have the same MX level, a round-robin configuration will be used to determine which server is tried first. Email will not be sent to both email servers.