SMTPlib inside function, extra tab

Hunter hunterji at gmail.com
Wed Oct 8 22:35:57 EDT 2008


Thank you Tino.  I appreciate the help.

Duh!  Anything inside """ """ is preformatted text.  I have tabs
inside my preformatted text (without even thinking because it looks
more normal because of the indent).  I removed them and voila!

def send_mail(fromaddress,tolist,msgsubj,messagebody):
        import smtplib
        SERVER = "mymailserver.mydomain.com"
        message = """\
From: %s
To: %s
Subject: %s
%s
        """ % (fromaddress, ", ".join(tolist),msgsubj, messagebody)
        print message
        server = smtplib.SMTP(SERVER)
        server.set_debuglevel(1)
        server.sendmail(fromaddress, tolist, message)
        server.quit()

--Joshua



More information about the Python-list mailing list