Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- from email.mime.text import MIMEText
- import smtplib
- import time
- hostname = 'aaa'
- username = 'aaa'
- password = 'aaa'
- message="""
- Blah blah blah
- blah blah blah
- bla
- Att.
- Sr. Blah
- """
- with open('arquivo.txt','r') as f:
- content = f.readlines()
- for user in content:
- msg = MIMEText(message)
- msg['Subject'] = 'Blah blah bleh'
- msg['From'] = 'joao@nasa.com'
- server = smtplib.SMTP(hostname, 25)
- server.ehlo()
- server.starttls()
- server.ehlo()
- server.login(username, password)
- fromaddr = 'joao@nasa.com'
- user = user.replace('\n','').split(' ')[0]
- toaddr = "%s@nasa.com" % user
- msg['To'] = '%s@nasa.com' % user
- server.sendmail(fromaddr,toaddr,msg.as_string())
- time.sleep(5)
- server.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement