smtp question
Tim Roberts
timr at probo.com
Fri Jan 7 01:51:13 EST 2005
"Philippe C. Martin" <philippecmartin at sbcglobal.net> wrote:
>Hi,
>
>I am testing the smtp module and have the following question:
>
>in the code below (taken from net sample) prior to adding the "Subject:"
>field, the email client found the "From" and the "To". Without the
>"Subject:" field on I get this:
>
>Email client = Evolution: the "From" field is blank
>Email client = KMail: the "To" field is blank
>
>Any clue ?
Absolutely.
>server = smtplib.SMTP('smtp.sbcglobal.yahoo.com')
>server.set_debuglevel(1)
>server.login ('xxxxx','yyyyyyy')
>server.sendmail(fromaddr, toaddrs, 'Subject:from python\n\n'+msg)
>server.quit()
You have two newlines following the Subject: line. That inserts a blank
line, which terminates the headers. Everything else, including the From:
and To: lines, will be taken as part of the message body. I assume you
meant to use \r\n, but \n will work just as well and is less error prone.
>print "Message length is " + repr(len(msg))
Easier is:
print "Message length is", len(msg)
More efficient is:
print "Message length is %d" % len(msg)
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list