Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. from email.mime.text import MIMEText
  5. import smtplib
  6. import time
  7.  
  8. hostname = 'aaa'
  9. username = 'aaa'
  10. password = 'aaa'
  11.  
  12. message="""
  13. Blah blah blah
  14. blah blah blah
  15. bla
  16.  
  17. Att.
  18. Sr. Blah
  19. """
  20.  
  21.  
  22. with open('arquivo.txt','r') as f:
  23. content = f.readlines()
  24.  
  25. for user in content:
  26. msg = MIMEText(message)
  27. msg['Subject'] = 'Blah blah bleh'
  28. msg['From'] = 'joao@nasa.com'
  29.  
  30. server = smtplib.SMTP(hostname, 25)
  31. server.ehlo()
  32. server.starttls()
  33. server.ehlo()
  34. server.login(username, password)
  35. fromaddr = 'joao@nasa.com'
  36.  
  37. user = user.replace('\n','').split(' ')[0]
  38. toaddr = "%s@nasa.com" % user
  39. msg['To'] = '%s@nasa.com' % user
  40. server.sendmail(fromaddr,toaddr,msg.as_string())
  41. time.sleep(5)
  42. server.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement