Advertisement
Guest User

Untitled

a guest
Mar 16th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import os
  2. import smtplib
  3. from email.mime.text import MIMEText
  4. from email.mime.image import MIMEImage
  5. from email.mime.multipart import MIMEMultipart
  6.  
  7.  
  8.  
  9. img_data = open('abc.jpg', 'rb').read()
  10. msg = MIMEMultipart()
  11. msg['Subject'] = 'subject'
  12. msg['From'] = 'marek.wno95@gmail.com'
  13. msg['To'] = 'marek.wno95@gmail.com'
  14.  
  15. text = MIMEText("mail.txt")
  16. msg.attach(text)
  17. image = MIMEImage(img_data, name=os.path.basename('abc.jpg'))
  18. msg.attach(image)
  19.  
  20. s =smtplib.SMTP('smtp.gmail.com:587')
  21. s.ehlo()
  22. s.starttls()
  23. s.ehlo()
  24. s.login('marek.wno95@gmail.com', 'Ksemwetipg')
  25. s.sendmail('marek.wno95@gmail.com', 'marek.wno95@gmail.com', msg.as_string())
  26. s.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement