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 When a client connects to its SMTP server, an A type lookup for the server is done.

Say I’m sending mail to 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 domain. This MX lookup returns the location of the SMTP server for (see Resource records), and the ISP’s SMTP server sends the e-mail to the 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 using POP3. Piet’s mail client will do an A record for the addresses for, 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, has the following MX records: 1d IN MX 0 1d IN MX 0 1d IN MX 5 1d IN MX 5

In this case, and are the primary mail servers for (both will be used about equally often), and only if both are not available, and may be tried.

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