· 10 years ago · Dec 12, 2015, 04:36 PM
1#!/usr/bin/python #remember to create a .txt called bodytext
2# -*- coding: UTF-8 -*
3
4
5
6
7import sys
8import smtplib
9import getpass
10import time
11
12from sys import argv
13from email.MIMEMultipart import MIMEMultipart
14from email.MIMEText import MIMEText
15
16sprinklyline = "~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~" # Cus why not
17
18if len(sys.argv) != 2:
19 print sprinklyline
20 print 'Forgot to type target email? Example of usage:'
21 print '"python emailspam.py example@gmail.com"'
22 print sprinklyline
23else:
24 script, targetemail = argv
25
26 bodytext = open('bodytext.txt', 'r') # Open bodytext.txt
27 bodycontent = bodytext.read()
28
29 print sprinklyline
30 host = raw_input("Enter your email host (Gmail, Yahoo, etc): ")
31 if host == 'gmail' or 'Gmail' or 'GMAIL' or 'gMAIL':
32 server = smtplib.SMTP('smtp.gmail.com', 587) # Set GMAIL smtp server settings
33 server.starttls() # Start TLS
34 else:
35 print 'Work in progress for other email hosts'
36 quit()
37
38 print sprinklyline
39 emailusername = raw_input("Enter your Email username: ") # Email input
40 emailpassword = getpass.getpass("Enter your Email password: ") # Password input
41 emailsubject = raw_input("Enter email subject: ") # Subject input
42 print sprinklyline
43
44 server.login(emailusername, emailpassword) # Login to the smtp server
45
46 repeat = raw_input("Enter the amount of times you want to send this email (0 = Infinite): ")
47 delay = raw_input("Enter the amount of time to wait between each email (In seconds): ")
48
49 print "Please check your email for test email..."
50 # Sending a test email to check that everything works fine.
51 fromaddr = emailusername + '@gmail.com'
52 toaddr = emailusername + '@gmail.com'
53 msg = MIMEMultipart()
54 msg['From'] = fromaddr #From
55 msg['To'] = toaddr #To
56 msg['Subject'] = "Test Email successfuly sent! " + emailsubject #Subject
57 body = bodycontent #Body
58 msg.attach(MIMEText(body,'plain')) #Attach body to email
59 text = msg.as_string() #Output msg as a string
60 time.sleep(3)
61 print "Test email succesfuly recieved!"
62 print "Let the email spam begin!"
63 print sprinklyline
64
65 server.sendmail(fromaddr, toaddr, text)
66
67 if repeat == '0':
68 count = 1
69 while True:
70 time.sleep(int(delay))
71 fromaddr = emailusername + '@gmail.com'
72 toaddr = targetemail
73 msg = MIMEMultipart()
74 msg['From'] = fromaddr #From
75 msg['To'] = toaddr #To
76 msg['Subject'] = "[#" + str(count) + "] " + emailsubject #Subject
77 body = bodycontent #Body
78 msg.attach(MIMEText(body,'plain')) #Attach body to email
79 text = msg.as_string() #Output msg as a string
80
81 server.sendmail(fromaddr, toaddr, text) #Send the email
82
83 print ("Email #" + str(count) + "Sent successfuly!")
84 count += 1
85 else:
86 count = 1
87 while (count <= int(repeat)):
88 time.sleep(int(delay))
89 fromaddr = emailusername + '@gmail.com'
90 toaddr = targetemail
91 msg = MIMEMultipart()
92 msg['From'] = fromaddr #From
93 msg['To'] = toaddr #To
94 msg['Subject'] = "[#" + str(count) + "] " + emailsubject #Subject
95 body = bodycontent #Body
96 msg.attach(MIMEText(body,'plain')) #Attach body to email
97 text = msg.as_string() #Output msg as a string
98
99 server.sendmail(fromaddr, toaddr, text) #Send the email
100
101 print ("Email #" + str(count) + " Sent successfuly!")
102 count += 1