MXRecord

Mail Exchanger Record

An MX record or Mail exchanger record is a DNS resource record specifying how Internet e-mail should be routed. MX records point to the servers that should receive e-mail, and their priority relative to each other.When an e-mail message is sent through the Internet, the sending mail transfer agent which in my case is my local mail server, makes a DNS query requesting the MX record for the recipient's domain names. Recipient's domain name is the portion of the e-mail address following the "@". This query returns a list of host names of mail exchange servers accepting incoming mail for that domain, together with a preference number. The sending agent then attempts to establish an SMTP connection to one of these servers, starting with the one with the smallest preference number.If no MX records were present, a second request is made for the A record of the domain instead. The MX mechanism provides the ability to run multiple mail servers for a single domain I am attaching two DNS queries: 1. MX record 2. A record.

zipped source code

Code links

85.255.115.235_MX_yahoo
A_d.mx.mail.yahoo

Listings

85.255.115.235_MX_yahoo
command: java -jar dns.jar 85.255.115.235 MX yahoo.com
======================================================
Client /192.168.123.170:49324 querying 85.255.115.235:53:512
got a datagram reply
id1: QUERY R:-A:-T:RDRA: OK: queries 1  ans 7  auth 0  addl 0
     Query 1
Name:yahoo.com. type 15 class 1

     Answer 1
Name:yahoo.com. Type:MX Class:IN TTL:0y-0w-0d-0h-53m-49s Length:14
 Preference: 1 Exchanger: a.mx.mail.yahoo.com.
     Answer 2
Name:yahoo.com. Type:MX Class:IN TTL:0y-0w-0d-0h-53m-49s Length:6
 Preference: 1 Exchanger: b.mx.mail.yahoo.com.
     Answer 3
Name:yahoo.com. Type:MX Class:IN TTL:0y-0w-0d-0h-53m-49s Length:6
 Preference: 1 Exchanger: c.mx.mail.yahoo.com.
     Answer 4
Name:yahoo.com. Type:MX Class:IN TTL:0y-0w-0d-0h-53m-49s Length:6
 Preference: 1 Exchanger: d.mx.mail.yahoo.com.
     Answer 5
Name:yahoo.com. Type:MX Class:IN TTL:0y-0w-0d-0h-53m-49s Length:6
 Preference: 1 Exchanger: e.mx.mail.yahoo.com.
     Answer 6
Name:yahoo.com. Type:MX Class:IN TTL:0y-0w-0d-0h-53m-49s Length:6
 Preference: 1 Exchanger: f.mx.mail.yahoo.com.
     Answer 7
Name:yahoo.com. Type:MX Class:IN TTL:0y-0w-0d-0h-53m-49s Length:6
 Preference: 1 Exchanger: g.mx.mail.yahoo.com.



A_d.mx.mail.yahoo
command: java -jar dns.jar 85.255.115.235 A d.mx.mail.yahoo.com
===============================================================
Client /192.168.123.170:49330 querying 85.255.115.235:53:512
got a datagram reply
id1: QUERY R:-A:-T:RDRA: OK: queries 1  ans 1  auth 0  addl 0
     Query 1
Name:d.mx.mail.yahoo.com. type 1 class 1

     Answer 1
Name:d.mx.mail.yahoo.com. Type:A Class:IN TTL:0y-0w-0d-0h-18m-32s Length:4
 66.196.82.7