Guest User

Untitled

a guest
Jul 15th, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. import smtplib
  2. import time
  3. import datetime
  4. from email.mime.text import MIMEText
  5.  
  6. def send_message(sender, recips, message, subject):
  7.     senderName = 'AngryStudents@lakeheadu.ca'
  8.     recipients = recips
  9.  
  10.     msg = MIMEText(message)
  11.     msg['Subject'] =  subject
  12.     msg['From'] = sender[0]
  13.     msg['To'] = recipients[1]
  14.  
  15.     smtpserver = 'smtp.gmail.com'
  16.     smtpuser = sender[0]        
  17.     print (sender[0])
  18.     smtppass = sender[1]  
  19.     print (sender[1])
  20.  
  21.     session = smtplib.SMTP("smtp.gmail.com", 587)
  22.     session.ehlo()
  23.     session.starttls()
  24.     session.ehlo()
  25.  
  26.     session.login(smtpuser, smtppass)
  27.  
  28.     for recip in recips:
  29.         smtpresult = session.sendmail(senderName, [recip], msg.as_string())
  30.         print("sent from ", sender[0], " to ", recip, "at ", datetime.datetime.now())
  31.  
  32.     session.close()
  33.        
  34.  
  35.  
  36.  
  37. sender = [['garygrantgraham','ACTUALPASSWORDGOESHERE'],['test1','test2']]
  38. recipient = ['gggraham@lakeheadu.ca', 'garygrantgraham@gmail.com']
  39. messages = ['testing crap', 'heres a message', 'uh oh spam']
  40. subjects = ['What is Doctor allaire doing here?','RE: Allaires Tenured?!','CS program unbearable']
  41. random.seed()
  42.  
  43.  
  44. while(True):
  45.     send_message(sender[random.randint(0,1)], recipient, messages[random.randint(0,2), 'test e-mail!!')
  46.     time.sleep(15)
Add Comment
Please, Sign In to add comment