Skip to content

Instantly share code, notes, and snippets.

@bee-san
Created December 2, 2015 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bee-san/204428a686771e51f3a4 to your computer and use it in GitHub Desktop.
Save bee-san/204428a686771e51f3a4 to your computer and use it in GitHub Desktop.
# Import smtplib for the actual sending function
import smtplib
def main():
print("/t/tWelcome to the E-mail destroyer.")
target_email = input(("Please enter the email you wish to spam: "))
infinite_or_not = input("Would you like to infinitly spam an email? YES or NO.")
if infinite_or_not.upper().startswith("Y"):
infinite_or_not = True
else:
infinite_or_not = False
def send_email(DateTimeFinished):
import smtplib
File = open("log.txt", 'r')
FileContents = File.read()
File.close()
File=open("_ProgramLog.txt", 'r')
FileContents2 = File.readlines()
File.close()
# work
gmail_user = "brandonskerritt51@gmail.com"
# app specific password
gmail_pwd = ""
FROM = 'brandonskerritt51@gmail.com'
TO = ['brandonskerritt51@gmail.com'] # Must be a list -- This is blanked out as the TO address is obtained from Main()
SUBJECT = ("Sever Automation Email")
TEXT = ("The program ran at {} with no errors\n"
"\nThe program ran for {} seconds.\n"
"\nHere is the log file.\n"
"{}"
"\n"
"\n"
"\n"
"Here is the Program Log File\n"
"{}".format(DateTime, DateTimeFinished, FileContents, FileContents2))
# Prepare actual message
message = ("""\From: %s\nTo: %s\nSubject: %s\n\n%s""" % (FROM, ", ".join(TO), SUBJECT, TEXT))
try:
#server = smtplib.SMTP(SERVER)
server = smtplib.SMTP("smtp.gmail.com", 587) #or port 465 doesn't seem to work!
server.ehlo()
server.starttls()
server.login(gmail_user, gmail_pwd)
server.sendmail(FROM, TO, message)
#server.quit()
server.close()
print('successfully sent the mail')
except:
print("Failed to send mail")
# required in all programs, if the name "main" is called, run main()
# i do this instead of main() at the bottom so this can
# still be imported as a module
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment