Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using smtplib module, putting a subject in email 1

Status
Not open for further replies.

yannb

Technical User
Mar 12, 2003
3
US
i am using the smtplib module to send email from python script.

I would like to have a subject in the emails I send. but cant seem to figure out how to do that.

here's the script:

import smtplib
import string

fromaddr = 'foo@foo.com'
toaddr = 'foo@foo.com'

msg = ("From: %s\r\nTo: %s\r\n\r\n" % (fromaddr, toaddr))
msg += "test from python"
server = smtplib.SMTP('mail.foo.com')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddr, msg)
server.quit()

thanks

yann


 
toaddr = 'foo@foo.com'
subj = 'This is the subject!'

msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddr, subj))
msg += "test from python"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top