Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2015
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. # Import smtplib for the actual sending function
  2. import smtplib
  3.  
  4. def main():
  5. print("/t/tWelcome to the E-mail destroyer.")
  6. target_email = input(("Please enter the email you wish to spam: "))
  7. infinite_or_not = input("Would you like to infinitly spam an email? YES or NO.")
  8.  
  9. if infinite_or_not.upper().startswith("Y"):
  10. infinite_or_not = True
  11. else:
  12. infinite_or_not = False
  13.  
  14. def send_email(DateTimeFinished):
  15. import smtplib
  16.  
  17. File = open("log.txt", 'r')
  18. FileContents = File.read()
  19. File.close()
  20.  
  21. File=open("_ProgramLog.txt", 'r')
  22. FileContents2 = File.readlines()
  23. File.close()
  24.  
  25. # work
  26. gmail_user = "brandonskerritt51@gmail.com"
  27. # app specific password
  28. gmail_pwd = ""
  29. FROM = 'brandonskerritt51@gmail.com'
  30. TO = ['brandonskerritt51@gmail.com'] # Must be a list -- This is blanked out as the TO address is obtained from Main()
  31. SUBJECT = ("Sever Automation Email")
  32.  
  33. TEXT = ("The program ran at {} with no errors\n"
  34. "\nThe program ran for {} seconds.\n"
  35. "\nHere is the log file.\n"
  36. "{}"
  37. "\n"
  38. "\n"
  39. "\n"
  40. "Here is the Program Log File\n"
  41. "{}".format(DateTime, DateTimeFinished, FileContents, FileContents2))
  42.  
  43. # Prepare actual message
  44. message = ("""\From: %s\nTo: %s\nSubject: %s\n\n%s""" % (FROM, ", ".join(TO), SUBJECT, TEXT))
  45. try:
  46. #server = smtplib.SMTP(SERVER)
  47. server = smtplib.SMTP("smtp.gmail.com", 587) #or port 465 doesn't seem to work!
  48. server.ehlo()
  49. server.starttls()
  50. server.login(gmail_user, gmail_pwd)
  51. server.sendmail(FROM, TO, message)
  52. #server.quit()
  53. server.close()
  54. print('successfully sent the mail')
  55. except:
  56. print("Failed to send mail")
  57.  
  58.  
  59. # required in all programs, if the name "main" is called, run main()
  60. # i do this instead of main() at the bottom so this can
  61. # still be imported as a module
  62. if __name__ == '__main__':
  63. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement