subject with smtplib?

Jeff Sandys sandysj at juno.com
Mon Feb 23 18:15:17 EST 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 myisp.com"
frmadr = "myhost at myhost.com"
msg = "this is an important message."
server = smtplib.SMTP('localhost')
server.sendmail(frmadr, toadr, msg)
server.quit()

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.

Thanks,
Jeff Sandys



More information about the Python-list mailing list