Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.89 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3.  
  4. #Written by: d0n601
  5. #do with this script what you will, it's meant to be quick and simple.
  6.  
  7.  
  8. import smtplib
  9. import getpass
  10. from email.MIMEMultipart import MIMEMultipart
  11. from email.MIMEBase import MIMEBase
  12. from email.MIMEText import MIMEText
  13. from email import Encoders
  14. import os
  15.  
  16. bomb_count = 0
  17.  
  18. option = raw_input("Press L to login to a previously set default account. If you haven't hard coded defaults or want to enter a different login PRESS AY KEY")
  19.  
  20. if (option=="L") or (option=="l"):
  21.     user = "DEFAULT" # fill in default here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  22.     password = "DEFAULT" # fill in default here<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  23.     if(user=="DEFAULT"):
  24.         print "You haven't configured a default account. You must edit the script to do this, so for now please enter a login manually"
  25.         option = "x"
  26. if(option!="L") and (option!="l"):
  27.     user = raw_input("Enter Gmail account: example@gmail.com): ")
  28.     password = getpass.getpass("Enter Gmail password: ")
  29.  
  30. recip = raw_input("Enter recipient account: example@whatever.com): ")
  31. bomb = input("How many emails to send: Example '40' : ")
  32. sub = raw_input("Enter a Subject: ")
  33. body = raw_input("Enter body: ")
  34. Atch_Q = raw_input("Do you want to send an attatchment?  y/n ")
  35. if (Atch_Q=="y") or (Atch_Q=="Y"):
  36.     atch = raw_input("Input the path to attatchment: Example '/home/user/pictures/cornhole.jpg': ")
  37.  
  38.  
  39. def mail_A(to, subj, text, attach):
  40.     msg = MIMEMultipart()
  41.     msg['From'] = user
  42.     msg['To'] = to
  43.     msg['Subject'] = subj
  44.     msg.attach(MIMEText(text))
  45.     part = MIMEBase('application', 'octet-stream')
  46.     part.set_payload(open(attach, 'rb').read())
  47.     Encoders.encode_base64(part)
  48.     part.add_header('Content-Disposition','attachment; filename="%s"' % os.path.basename(attach))
  49.     msg.attach(part)
  50.     mailServer = smtplib.SMTP("smtp.gmail.com", 587)
  51.     mailServer.ehlo()
  52.     mailServer.starttls()
  53.     mailServer.ehlo()
  54.     mailServer.login(user, password)
  55.     mailServer.sendmail(user, to, msg.as_string())
  56.     mailServer.close()
  57. def mail(to, subj, text):
  58.     msg = MIMEMultipart()
  59.     msg['From'] = user
  60.     msg['To'] = to
  61.     msg['Subject'] = subj
  62.     msg.attach(MIMEText(text))
  63.     part = MIMEBase('application', 'octet-stream')
  64.     Encoders.encode_base64(part)
  65.     mailServer = smtplib.SMTP("smtp.gmail.com", 587)
  66.     mailServer.ehlo()
  67.     mailServer.starttls()
  68.     mailServer.ehlo()
  69.     mailServer.login(user, password)
  70.     mailServer.sendmail(user, to, msg.as_string())
  71.     mailServer.close()
  72.  
  73. if (Atch_Q=="y") or (Atch_Q=="Y"):
  74.     while(bomb_count < bomb ):
  75.         mail_A(recip, sub, body, atch)
  76.         bomb_count += 1
  77.         print 'Message ', bomb_count, ' sent'
  78. else:
  79.     while(bomb_count < bomb ):
  80.         mail(recip, sub, body)
  81.         bomb_count += 1
  82.         print 'Message ', bomb_count, ' sent'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement