subject with smtplib?

Jeff Sandys sandysj at
Tue Feb 24 00:15:17 CET 2004

Can you include a subject with sendmail using smtplib?

When I do this (names changed to protect the innocent):

import smtplib
toadr = "me at"
frmadr = "myhost at"
msg = "this is an important message."
server = smtplib.SMTP('localhost')
server.sendmail(frmadr, toadr, msg)

I get the important message with a blank subject line.
It would be really useful to add a subject line, 

sub = "important message"
server.sendmail(frmadr, toadr, msg, subject=sub)

I've looked through the documentation and see that 
there is a mail_options but haven't found anything 
about adding a subject.

Jeff Sandys

More information about the Python-list mailing list