import zipfile
import smtplib
def archive_log(src, dst):
"""
Archiving log file to zip
"""
zip = zipfile.ZipFile(dst, 'w')
zip.write(src, os.path.basename(src), zipfile.ZIP_DEFLATED)
zip.close()
def send_email_report2(self):
SEND_TO = ['xxx@yyy.com']
SMTP_IP = '0.0.0.0'
msg = MIMEMultipart()
msg['From'] = 'xxx@yyy'
msg['To'] = COMMASPACE.join(SEND_TO)
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = 'Subject'
msg.attach(MIMEText('bodu text'))
for file_link in link_attachments:
part = MIMEBase('application', "octet-stream")
part.set_payload(open(file_link, "rb").read())
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(file_link))
msg.attach(part)
smtp = smtplib.SMTP(SMTP_IP)
smtp.sendmail('xxx1@yyy.com', SEND_TO, msg.as_string())
smtp.close()