smtplib - missing message

Peter Hansen peter at engcorp.com
Fri May 14 09:30:29 EDT 2004


alastair wrote:

> I'm trying to send an email using smtplib ....
 > When I look at the received mail, the
> text I send is not there - does anyone know why this is the case ?
> 
> Here's the code I've been using:
> fromClause = "me at me.com"
> toClause = "you at yahoo.co.uk"
> 
> msg = "Please display me."
> 
> server.sendmail(fromClause, toClause, msg)

RFC2822 (or whatever it is) specifies that a mail message has
headers, separated from the body of the message by an extra
newline. (Or is it a CRLF combination?  You can look that up
yourself.)  You don't have any header in your message, so
you'll have to add one, something like:

msg = "Subject: test\n\nPlease display me."

Note the double newline to mark the end of the header fields.

-Peter



More information about the Python-list mailing list