Advertisement
Guest User

Untitled

a guest
Jun 6th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import email
  2. import imaplib
  3. import smtplib
  4. import os
  5. import cv2
  6. from email.mime.text import MIMEText
  7. from email.mime.image import MIMEImage
  8. from email.mime.multipart import MIMEMultipart
  9.  
  10. server = smtplib.SMTP('smtp.gmail.com', 587)
  11. server.ehlo()
  12. server.starttls()
  13.  
  14. server.login("wnolaborki123@gmail.com", "mateusz321")
  15.  
  16. #img_data = cv2.imread('EA0.jpg', 0)
  17.  
  18. msg = MIMEMultipart()
  19. text = MIMEText("test")
  20. msg.attach(text)
  21. img_data = open('/Users/mateuszstolowski/PycharmProjects/MetodyNummeryczne/obrazek0.png', 'rb')
  22. image = MIMEImage(img_data.read())
  23. msg.attach(image)
  24.  
  25.  
  26. server.sendmail("wnolaborki123@gmail.com", "wnolaborki123@gmail.com", msg.as_string())
  27.  
  28.  
  29. # pop.gmail.com
  30. # 995
  31. # /Users/mateuszstolowski/PycharmProjects/MetodyNummeryczne
  32.  
  33. import poplib
  34.  
  35. pop3server = 'pop.gmail.com'
  36. username = 'wnolaborki123@gmail.com'
  37. password = 'mateusz321'
  38. pop3server = poplib.POP3_SSL(pop3server, 995) # open connection
  39. print(pop3server.getwelcome()) # show welcome message
  40. pop3server.user(username)
  41. pop3server.pass_(password)
  42. pop3info = pop3server.stat() # access mailbox status
  43. mailcount = pop3info[0] # toral email
  44. print("Total no. of Email : ", mailcount)
  45. print("\n\nStart Reading Messages\n\n")
  46. for i in range(mailcount):
  47. for message in pop3server.retr(i + 1)[1]:
  48. print(message)
  49. pop3server.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement