There is often a lot of confusion about how email and DNS services actually interact and why DNS is important for email delivery. This attempts to be a brief explaination of how it all works. -- AdamShand
Under normal circumstances the delivery of email works like this:
I try and send mail to you at joe@example.com.
- My client sends mail to my mail server.
- My mail server looks up the MX (Mail eXchanger) records for example.com from DNS. You can discover the MX records for a domain by using one of the DNS tools, for example from a Linux box you can do:
# host -t mx spack.org spack.org mail is handled by 10 maus.spack.org. spack.org mail is handled by 20 grin.gnosh.net.
- My mail server sends the email to the highest priority MX (the one with the lowest number) for the domain.
- The example.org mail server does whatever it needs to do to deliver the message to joe.
Now lets assume that there is only one DNS server and it's down.
I try and send mail to you at joe@example.com.
- My client sends mail to my mail server.
- My mail server tries to look up the MX records for example.com but fails to reach an authoritive name server.
- My mail server decides that example.com doesn't exist and the email immediately bounces back to me as undeliverable. It is a permenant failure and will not be tried again in the future.
Now what if primary DNS is down, but secondary DNS is up and the mail server is down.
I try and send mail to you at joe@example.com.
- My client sends mail to my mail server.
- My mail server looks up the MX records for example.com from DNS. It fails to get DNS information from the first server but suceeds from the second.
- My mail server tries to deliver mail to the mail server for example.com but can't reach it. It understands that this is probably a temporary issue and holds onto the message and will try again every X hours for Y days.
- Every Z hours for I will get a warning message telling me that the mail server for example.com is down and that it is still trying to send my message. If the mail server isn't up after ? days it will give up and send me a message saying so.
Now what if primary DNS is down, secondary DNS is up, primary email is down but secondary email is up.
I try and send mail to you at joe@example.com.
- My client sends mail to my mail server.
- My mail server looks up the MX records for example.com from DNS. It fails to get DNS information from the first server but suceeds from the second.
- My mail server tries to send email to the primary MX for example.com and fails to reach it.
- It looks to see if there is another MX record for the domain, since there is a secondary MX for example.com it resends the message to that server.
- The secondary server knows that it's a backup mail server and will patiently hold onto my message waiting for the primary one to come back online. It may or may not be configured to send warning messages. If the primary server still isn't available after X days it will give up and bounce the message back to me saying that it was undeliverable.