Does smtplib lookup MX records?

Skip Montanaro skip at pobox.com
Fri Nov 16 12:01:25 EST 2001


    Dale> If it is, what do I need to do to lookup the MX record myself?

There are some DNS bits floating around.  You might want to try googling for
"DNS ~g comp.lang.python".

If you're on a Unix-oid system and you're really in a hurry, why not just
use os.popen:

    import os

    f = os.popen("host -t mx mojam.com")
    for line in f:
        if line.find("mail is handled by") != -1:
            print "mx:", line.rstrip().split()[-1]

this-hack-was-brought-to-you-by-the-letter-X-and-the-number-5-ly, y'rs,

Skip




More information about the Python-list mailing list