When you send an e-mail, first your e-mail client software forwards the message to an e-mail server. When an e-mail message is sent through the Internet, the sending mail transfer agent (MTA) queries the DNS for MX records of recipient's domain name.

This query returns a list of host names of mail exchange servers accepting incoming mail for that domain and their preferences. The sending agent then attempts to establish an SMTP connection.

The MX mechanism provides the ability to run multiple mail servers for a single domain and allows administrators to specify an order in which they should be tried.

Preference or Priority

The lowest-numbered records are the most preferred. So, the preference number is sometimes referred to as the distance: smaller distances are more preferable.

For a simple case where a domain have just one mail server, then the MTA will attempt delivery of the mail to the server listed. In this case, the preference number can be any integer permitted by the SMTP specification. But when more than one server is returned for an MX query, the preference number for each record dictates the relative priority of the listed server.

Example

A typical MX-record looks something like this:

example.com. 3600 IN MX 0 mail.example.com.

There are two numeric values in the above record. The first one is 3600, which is the TTL (Time to Live). This record tells other DNS-servers and clients to cache the above record for up to 3600 seconds (one hour). The second numerical value is '0' and it is the MX-record priority. If there are multiple records, it determines the priority order of the servers. If the first one fails, the second one is used, and so on.

How Mail Servers Work

Every mail server that lets you send and receive email with a local mail client has three separate software components:

  1. MTA: The Mail Transfer Agent relays mail between your server and the Internet, whether it is delivering an outside email to you, or sending an email from you. Accepted incoming mail gets added to the MTA’s queue on the server.

  2. MDA: The Mail Delivery Agent takes mail from the MTA’s queue and saves it to individual mailboxes.

  3. IMAP/POP3 Server: It manages users and their mailboxes as they check their email over IMAP/POP3 connections.

The Mail Server Process

  1. An incoming message is directed to your mail server via DNS.

  2. Once it passes through the MTA and MDA, it is stored in the mailbox on the server.

  3. When the message is requested, the IMAP/POP3 server mediates the connection between the server and the user’s local mail client.

  4. Outgoing mail is sent from the user’s local mail client, processed by MTA, and is then sent to its destination on the Internet.

Different Hosting for Website and Email

First, you need to add an A Record for mail.yourdomain.com to the IP address of your mail service provider. Then, go to "MX Entry" and choose "Remote Mail Exchanger". Then, delete any previous MX record. Now, add mail.yourdomain.com in destination and priority as 0 (zero).