When an email is sent, the sending server queries the DNS to find the MX records of the recipient's domain. The records list the mail servers and their priority levels. The email is then routed to the mail server with the highest priority (lowest number). If that server is unavailable, the next highest priority server is used, and so on.