Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding mail exchangers

4 views
Skip to first unread message

ian

unread,
May 13, 2002, 1:47:35 PM5/13/02
to
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 iwa...@btclick.com
it gets sent to pop3.btclick.com

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


Steve Holden

unread,
May 13, 2002, 10:57:29 PM5/13/02
to
"ian" <iwa...@btclick.com> wrote in message
news:0eSD8.57422$7R.66720@NewsReader...


You need to submit a query to a DNS server and decode the reply.

I have code that does this if you'd like a copy (it uses the dnslib code,
which I can also provide).

regards
Steve
--
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------

Anthony Baxter

unread,
May 13, 2002, 11:47:50 PM5/13/02
to

>>> "Steve Holden" wrote

> You need to submit a query to a DNS server and decode the reply.

Look at the code in pydns.sf.net - there's a function in the lazy module
called "mxlookup". For instance,

>>> import DNS
>>> DNS.DiscoverNameServers() # win or unix, initialise resolver.
>>> DNS.mxlookup('interlink.com.au')
[(0, 'mx1.interlink.com.au'), (50, 'mx2.interlink.com.au')]

> I have code that does this if you'd like a copy (it uses the dnslib code,
> which I can also provide).

How does your dnslib differ from Guido's original code?

Anthony
--
Anthony Baxter <ant...@interlink.com.au>
It's never too late to have a happy childhood.

Steve Holden

unread,
May 14, 2002, 12:57:04 AM5/14/02
to
"Anthony Baxter" <ant...@interlink.com.au> wrote in message
news:mailman.1021348163...@python.org...

>
> >>> "Steve Holden" wrote
> > You need to submit a query to a DNS server and decode the reply.
>
> Look at the code in pydns.sf.net - there's a function in the lazy module
> called "mxlookup". For instance,
>
> >>> import DNS
> >>> DNS.DiscoverNameServers() # win or unix, initialise resolver.
> >>> DNS.mxlookup('interlink.com.au')
> [(0, 'mx1.interlink.com.au'), (50, 'mx2.interlink.com.au')]
>
Sounds like the perfect solution - I'll suggest that instead of my own hack
in future.

> > I have code that does this if you'd like a copy (it uses the dnslib
code,
> > which I can also provide).
>
> How does your dnslib differ from Guido's original code?

At this distance in time it's hard to say. Probably not at all, but there
was a time when dnslib wasn't always distributed.

Anyhway, since we seem to be in an ongoing problem solved situation, thanks
for the information.

Paul Wright

unread,
May 14, 2002, 6:11:03 AM5/14/02
to
In article <0eSD8.57422$7R.66720@NewsReader>, ian <iwa...@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 iwa...@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 |

ian

unread,
May 14, 2002, 8:13:04 AM5/14/02
to
cheers for the help guys


"Paul Wright" <-$P-W$-@verence.demon.co.uk> wrote in message
news:abqnrn$3c9$1...@verence.demon.co.uk...

0 new messages