Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- message = MIMEMultipart("alternative")
- message["Subject"] = "TEST"
- message["From"] = 'X'
- message["To"] = ', '.join(email_dest)
- html = """
- <html>
- <body>
- <h2>TEST</h2>
- <p>TEST PLATFORM
- <img src="imgTest.png">
- </p>
- </body>
- </html>
- """
- part2 = MIMEText(html, "html")
- message.attach(part2)
- with open('C:\Users\admin\Documents\examples_py\imgTest.png', 'rb') as f:
- mime = MIMEBase('image', 'png', filename='imgTest.png')
- mime.add_header('Content-Disposition', 'attachment', filename='imgTest.png')
- mime.add_header('X-Attachment-Id', '0')
- mime.add_header('Content-ID', '<0>')
- mime.set_payload(f.read())
- encoders.encode_base64(mime)
- message.attach(mime)
- connection = smtplib.SMTP('smtp.gmail.com', 587)
- connection.ehlo()
- connection.starttls()
- connection.login(email_src, passwd)
- connection.sendmail(email_src, email_dest, message.as_string())
- connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement