I am using the below piece of code to send attachments. But the attachments are being inlined. They do not arrive as attachments. I would like to send multiple attachments. Anythoughts to solve this problem ? Thanks import sys, smtplib, MimeWriter, base64, StringIO def SendMailExt(self): REQUEST = self.REQUEST FILE = REQUEST.form['fileget'] message = StringIO.StringIO() writer = MimeWriter.MimeWriter(message) writer.addheader('Subject', 'TEST REQUEST FROM ATT') writer.startmultipartbody('mixed') # start off with a text/plain part part = writer.nextpart() body = part.startbody('text/plain') body.write('This is a test mail from Auto Test Tool :)') # now add an image part part = writer.nextpart() part.addheader('Content-Transfer-Encoding', 'base64') body = part.startbody('text/plain') base64.encode(open(FILE.filename, 'rb'), body) # finish off writer.lastpart() # send the mail smtp = smtplib.SMTP('mercury.sophos') smtp.sendmail('Auto Test Tool@sophos.com', 'rama.govardhana@sophos.com', message.getvalue()) smtp.quit() return 'Request Sent\n'
Rama.Govardhana@sophos.com wrote at 2004-12-9 16:03 +0000:
I am using the below piece of code to send attachments. But the attachments are being inlined. They do not arrive as attachments. I would like to send multiple attachments.
You want to learn about the "content-disposition" header. It controls whether a submessage is treated inline or as attachment. -- Dieter
participants (2)
-
Dieter Maurer -
Rama.Govardhanaï¼ sophos.com