Commit 9ba17dbc authored by Kevin Deldycke's avatar Kevin Deldycke

Add an exemple of how to send the report to many adresses


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4146 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 741b7d66
...@@ -9,32 +9,40 @@ from email.MIMEBase import MIMEBase ...@@ -9,32 +9,40 @@ from email.MIMEBase import MIMEBase
from email.MIMEImage import MIMEImage from email.MIMEImage import MIMEImage
from email.MIMEMultipart import MIMEMultipart from email.MIMEMultipart import MIMEMultipart
COMMASPACE = ', ' COMMASPACE = ', '
USER = 'seb'
subject = 'ERP5 Unit Test'
from_mail = 'seb@nexedi.com'
to_mail = [ 'erp5-report@nexedi.com'
# , 'seb@nexedi.com'
,
]
test_msg = file('/home/seb/zope/Products/test_output','r').read() test_msg = file("/home/%s/zope/Products/test_output" % (USER),'r').read()
test_msg = "Date : %s\n\n" % date.today().isoformat() + test_msg test_msg = "Date : %s\n\n" % date.today().isoformat() + test_msg
#msg.set_payload(test_msg) #msg.set_payload(test_msg)
msg = MIMEMultipart() msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = from_mail
msg['To'] = COMMASPACE.join(to_mail)
#msg['content-type']=test_msg #msg['content-type']=test_msg
msg['Subject'] = 'ERP5 Unit Test'
from_mail = "seb@nexedi.com"
msg['From'] = from_mail
to_mail = "erp5-report@nexedi.com"
msg['To'] = to_mail
#msg.preamble = 'ERP5 Unit Test'
# Guarantees the message ends in a newline # Guarantees the message ends in a newline
msg.preamble = 'ERP5 Unit Test' msg.preamble = subject
msg.epilogue = '' msg.epilogue = ''
file_content = file('/home/seb/zope/Products/test_full_output','r').read() file_content = file("/home/%s/zope/Products/test_full_output" % (USER),'r').read()
mime_text = MIMEText(test_msg) mime_text = MIMEText(test_msg)
mime_text.add_header('Content-Disposition', 'attachment', filename='test_output') mime_text.add_header('Content-Disposition', 'attachment', filename='test_output')
msg.attach(mime_text) msg.attach(mime_text)
mime_text = MIMEText(file_content) mime_text = MIMEText(file_content)
mime_text.add_header('Content-Disposition', 'attachment', filename='test_full_output') mime_text.add_header('Content-Disposition', 'attachment', filename='test_full_output')
msg.attach(mime_text) msg.attach(mime_text)
# Send the email via our own SMTP server. # Send the email via our own SMTP server.
s = smtplib.SMTP() s = smtplib.SMTP()
s.connect() s.connect()
s.sendmail(from_mail, to_mail, msg.as_string()) s.sendmail(from_mail, to_mail, msg.as_string())
s.close() s.close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment