Does smtplib lookup MX records?
donn at u.washington.edu
Fri Nov 16 18:27:06 CET 2001
Quoth Dale Strickland-Clark <dale at riverhall.NOTHANKS.co.uk>:
| I've been trying to send emails with smtplib and had a large number of
| failures. Investigation seems to reveal the the smtplib module does a
| simple connect passing the hostname to socket.connect without trying
| to resolve the MX record.
| In some cases this works where the mail server happens to have an
| A-type DNS record anyway but otherwise it fails with a connection
| Is this really the case?
| If it is, what do I need to do to lookup the MX record myself?
I have never used it for anything, but you can find a Python DNS
client implementation in the source directory Demo/dns, if that
helps. Note that you have to specify the DNS server, and you'll
have to decide who that is somehow according to site & platform.
You may find that it will in turn refer you to another authoritative
DNS server where you get the answer.
A C module that calls res_search() would be another option.
Donn Cave, donn at u.washington.edu
More information about the Python-list