Using DNS for e-mail

One major use of DNS is for delivering e-mail.

Let’s do a quick introduction into how e-mail works, and how DNS comes into play, first. When you send an e-mail, you send it to a SMTP server, presumably the SMTP server of your provider. For example, I have set my e-mail client to send mail using the SMTP server mail.wanadoo.nl.. When a client connects to its SMTP server, an A type lookup for the server is done.

Say I’m sending mail to piet@mail.nu. The SMTP server for my provider gets this e-mail message, and it will determine where to deliver the mail by doing an MX type lookup for the mail.nu. domain. This MX lookup returns the location of the SMTP server for mail.nu. (see Resource records), and the ISP’s SMTP server sends the e-mail to the mail.nu. SMTP server. This mail server will notice the e-mail is for one of its local users, and store the e-mail locally.

Now, Piet has configured its mail client to get mail from pop3.mail.nu. using POP3. Piet’s mail client will do an A record for the addresses for pop3.mail.nu., connect to one of them, and retrieve my e-mail message.

In summary, when end users send or retrieve mail, they use A record lookups, but when delivering mail, SMTP servers internally use MX records. So how do these MX records look like? A MX record has two fields (for details, see Resource records): one is the priority value, and one is the domain name for the SMTP server. When there are multiple MX records, the mail servers with lowest priority value are tried first, and only if all servers with low priority value fail, servers with higher priority are tried.

For example, mail.nu. has the following MX records:

mail.nu. 1d IN MX 0 sitemail.everyone.net.
mail.nu. 1d IN MX 0 sitemail2.everyone.net.
mail.nu. 1d IN MX 5 sitemail3.everyone.net.
mail.nu. 1d IN MX 5 sitemail4.everyone.net.

In this case, sitemail.everyone.net. and sitemail2.everyone.net. are the primary mail servers for mail.nu. (both will be used about equally often), and only if both are not available, sitemail3.everyone.net. and sitemail4.everyone.net. may be tried.

 
  dns/using_dns_for_e-mail.txt · Last modified: 2005/01/10 14:24
 
Copyright © Meilof Veeningen, 2002-2005 - About Posadis.org