SHARE
TWEET

Untitled

a guest Jul 12th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. message = MIMEMultipart("alternative")
  2.        message["Subject"] = "TEST"
  3.        message["From"] = 'X'
  4.        message["To"] = ', '.join(email_dest)
  5.  
  6.        html = """
  7.              <html>
  8.                <body>
  9.                  <h2>TEST</h2>
  10.                    <p>TEST PLATFORM
  11.                     <img src="imgTest.png">
  12.                     </p>
  13.                 </body>
  14.               </html>
  15.          """
  16.  
  17.         part2 = MIMEText(html, "html")
  18.         message.attach(part2)
  19.       with          open('C:\Users\admin\Documents\examples_py\imgTest.png', 'rb') as f:
  20.        mime = MIMEBase('image', 'png',          filename='imgTest.png')
  21.        mime.add_header('Content-Disposition', 'attachment', filename='imgTest.png')
  22.        mime.add_header('X-Attachment-Id', '0')
  23.        mime.add_header('Content-ID', '<0>')
  24.        mime.set_payload(f.read())
  25.        encoders.encode_base64(mime)
  26.        message.attach(mime)
  27.  
  28.        connection = smtplib.SMTP('smtp.gmail.com', 587)
  29.        connection.ehlo()
  30.        connection.starttls()
  31.        connection.login(email_src, passwd)
  32.        connection.sendmail(email_src, email_dest,       message.as_string())
  33.        connection.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top