[Tutor] content disposition header: email module
Justin Ezequiel
justin.mailinglists at gmail.com
Thu Sep 7 03:15:17 CEST 2006
try something like the following (UNTESTED) code:
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.Message import Message
def attch_send(self):
msg = MIMEMultipart()
#msg.add_header("From", sender)
#msg.add_header("To", recv)
msg.attach(MIMEText('file(s) attached')) # the body text
attachment = Message()
attachment.add_header('Content-type', 'text/plain',
name="web-list.txt")
attachment.add_header('Content-Disposition', 'attachment',
filename="web-list.txt")
attachment.set_payload(file(os.path.join(save_dir,"web-list.txt")).read())
msg.attach(attachment)
server = smtplib.SMTP('localhost')
#server.set_debuglevel(1)
server.sendmail(sender, recv, msg.as_string())
server.quit()
More information about the Tutor
mailing list