Skip to content

Instantly share code, notes, and snippets.

@fschatbot
Created February 22, 2022 01:00
Show Gist options
  • Save fschatbot/fc05909f74f8ade2f983239f2bf90661 to your computer and use it in GitHub Desktop.
Save fschatbot/fc05909f74f8ade2f983239f2bf90661 to your computer and use it in GitHub Desktop.
Python Mail Flooder
#!/usr/bin/python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import getpass
import time
# Sender Info Here
EMAIL_ADRESS = input("What is your email address?\n» ")
PASSWORD = getpass.getpass('Please Enter Your Email Password\n» ') # This is used to hide the password when entering it, so you can run this script without your peers knowing your password
# Reciver Info Here
people_amt = int(input("No.of people do you want to send the mail to?\n» "))
receivers = [input(f"Email adress of your {x+1}th person?\n» ") for x in range(people_amt)]
sender = EMAIL_ADRESS
# Message Info Here
SUBJECT = 'Hello :D'
MESSAGE = 'Hey, guess what? These mails should not stack!'
MAIL_COUNT = int(input("How many mails do you want to send?\n» "))
# This is to check wheter the email adress and password given was correct or not
try:
smtpObj = smtplib.SMTP('smtp.gmail.com:587')
smtpObj.ehlo()
smtpObj.starttls()
smtpObj.login(EMAIL_ADRESS, PASSWORD)
smtpObj.close()
except:
print("Hey ethier of these things has happened, please check!")
print("1. Incorrect Email Adress or Password")
print("2. You don't have \"allow less secure apps\" enabled in your gmail account [https://myaccount.google.com/lesssecureapps]")
print("3. You are not connected to internet")
exit()
# Creating the message
def create_message(count):
message = MIMEMultipart()
message['From'] = sender
message['To'] = ", ".join(receivers)
message['Subject'] = f"{SUBJECT} ({count})"
message.attach(MIMEText(MESSAGE))
return message.as_string()
for i in range(MAIL_COUNT):
time.sleep(0.4) # Sleep for 0.4 secounds (Not Doing this will result in stacked messages)
smtpObj = smtplib.SMTP('smtp.gmail.com:587')
smtpObj.ehlo()
smtpObj.starttls()
smtpObj.login(EMAIL_ADRESS, PASSWORD)
smtpObj.sendmail(sender, receivers, create_message(i+1))
smtpObj.close()
# Simple Print Statements to state the progress and when the entire thing is done
print(f"\r[+] Email sent [{i + 1}][{(i+1)/MAIL_COUNT * 100:,.1f}%]", end='') # This prints the progress in the same line with the cursor at the end
print("\nAll the mails have been sent") # This is to deal with the last line of the progress bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment