Finding mail exchangers

Paul Wright -$P-W$- at verence.demon.co.uk
Tue May 14 06:11:03 EDT 2002


In article <0eSD8.57422$7R.66720 at NewsReader>, ian <iwaters at btclick.com> wrote:
>hi ive almost finished my mail server for a
>programming assignment im doing
>
>what i need to do now is write some code
>to find the mail exchanger for a given domain
>
>for example if i send mail to iwaters at btclick.com
>it gets sent to pop3.btclick.com

No, it gets sent to one of
btclick.com             MX      10 smtp.btclick.com
btclick.com             MX      5 mail.btclick.com

(this is the output of "host -t MX btclick.com" on Linux. The "dig"
command would give something similar).

>how can i get a list of all exchangers for domains?

Do an MX lookup using PyDNS: http://pydns.sourceforge.net/

Note that not all domains will have an MX record, so you'd need to check
for A records if you don't find a mail exchanger.

The right thing for a client program to do is send the mail on to a
'smarthost' which will do the lookups for you and handle queuing and
retries and suchlike. But I'm assuming that, as your assignment is to
write a server, this isn't an option for you.

-- 
Paul Wright | http://pobox.com/~pw201 |



More information about the Python-list mailing list