MIMEMultipart cuts attached file
Achim Domma (Procoders)
domma at procoders.net
Fri Sep 10 08:58:21 EDT 2004
Hi,
I try to send a mulitpart email, which should have a body and two
attached files: a html file and a zip file. My code looks like this:
msg=MIMEMultipart()
msg['From']=sender
msg['To']='; '.join(recipients)
msg['Subject']=subject
msg.epilogue=''
html=file(reportFile,'rb').read()
report=MIMEText(html,'html')
report.add_header('Content-Disposition','attachment',filename=reportFile)
msg.attach(report)
data=file(diffFile,'rb').read()
diff=MIMEBase('application','zip')
diff.set_payload(data)
encode_base64(diff)
diff.add_header('Content-Disposition','attachment',filename=diffFile)
msg.attach(diff)
text=MIMEText("the body text",'plain')
msg.attach(text)
smtp=smtplib.SMTP('pop_server')
smtp.set_debuglevel(0)
smtp.sendmail(sender,recipients,msg.as_string())
smtp.quit()
The body of the mail is ok and the zip archive is also valid, but the
end of the html is cut of most of the time.
Any hints what I'm doing wrong?
regards,
Achim
More information about the Python-list
mailing list