Subject with SMTPLIB?

Gregory Jorgensen gregj at
Tue Mar 13 10:35:42 CET 2001

You need to add a subject header to your message. Email message format is
simple: headers, blank line, message body.

import smtplib

msg = "subject: hello, world!\n\nmessage body"

s = smtplib.SMTP(host)
s.sendmail(fromaddr, toaddrs, msg)

You'll find a good SMTP quick reference on Dan Bernstein's site (he's the author
of qmail). See

In article <3AADE48A.5D8AA43 at>, root says...
>I need to write some mail for my fax-log evaluating script. I'm
>currently using
>the smtplib to simply send some mails. But how can I get (without
>studying RFCs
>and papers on SMTP for years)  a SUBJECT for my mails? It must be
>this easy, but the library reference in the python documentation package
>me nothing about it.  I was disappointed that the documentation on the
>module didn't tell me that.

Greg Jorgensen
Deschooling Society
Portland, Oregon, USA
gregj at

More information about the Python-list mailing list