Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- import time
- import datetime
- from email.mime.text import MIMEText
- def send_message(sender, recips, message, subject):
- senderName = 'AngryStudents@lakeheadu.ca'
- recipients = recips
- msg = MIMEText(message)
- msg['Subject'] = subject
- msg['From'] = sender[0]
- msg['To'] = recipients[1]
- smtpserver = 'smtp.gmail.com'
- smtpuser = sender[0]
- print (sender[0])
- smtppass = sender[1]
- print (sender[1])
- session = smtplib.SMTP("smtp.gmail.com", 587)
- session.ehlo()
- session.starttls()
- session.ehlo()
- session.login(smtpuser, smtppass)
- for recip in recips:
- smtpresult = session.sendmail(senderName, [recip], msg.as_string())
- print("sent from ", sender[0], " to ", recip, "at ", datetime.datetime.now())
- session.close()
- sender = [['garygrantgraham','ACTUALPASSWORDGOESHERE'],['test1','test2']]
- recipient = ['gggraham@lakeheadu.ca', 'garygrantgraham@gmail.com']
- messages = ['testing crap', 'heres a message', 'uh oh spam']
- subjects = ['What is Doctor allaire doing here?','RE: Allaires Tenured?!','CS program unbearable']
- random.seed()
- while(True):
- send_message(sender[random.randint(0,1)], recipient, messages[random.randint(0,2), 'test e-mail!!')
- time.sleep(15)
Add Comment
Please, Sign In to add comment