[Zope] Email Attachments
Rama.Govardhana at sophos.com
Rama.Govardhana at sophos.com
Thu Dec 9 11:03:17 EST 2004
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 at sophos.com',
'rama.govardhana at sophos.com', message.getvalue())
smtp.quit()
return 'Request Sent\n'
More information about the Zope
mailing list