diff --git a/EmailSender/Subscribers.xlsx b/EmailSender/Subscribers.xlsx new file mode 100644 index 0000000..0840935 Binary files /dev/null and b/EmailSender/Subscribers.xlsx differ diff --git a/EmailSender/__pycache__/add_email.cpython-38.pyc b/EmailSender/__pycache__/add_email.cpython-38.pyc new file mode 100644 index 0000000..a64168f Binary files /dev/null and b/EmailSender/__pycache__/add_email.cpython-38.pyc differ diff --git a/EmailSender/__pycache__/quick_guide.cpython-38.pyc b/EmailSender/__pycache__/quick_guide.cpython-38.pyc new file mode 100644 index 0000000..5cce1fb Binary files /dev/null and b/EmailSender/__pycache__/quick_guide.cpython-38.pyc differ diff --git a/EmailSender/__pycache__/send_email.cpython-38.pyc b/EmailSender/__pycache__/send_email.cpython-38.pyc new file mode 100644 index 0000000..b3ca6a6 Binary files /dev/null and b/EmailSender/__pycache__/send_email.cpython-38.pyc differ diff --git a/EmailSender/__pycache__/spammer.cpython-38.pyc b/EmailSender/__pycache__/spammer.cpython-38.pyc new file mode 100644 index 0000000..7f19c30 Binary files /dev/null and b/EmailSender/__pycache__/spammer.cpython-38.pyc differ diff --git a/EmailSender/add_email.py b/EmailSender/add_email.py new file mode 100644 index 0000000..84e8670 --- /dev/null +++ b/EmailSender/add_email.py @@ -0,0 +1,20 @@ +import openpyxl + + +def addSubscriber(): + filename = "Subscribers.xlsx" + openFile = openpyxl.load_workbook("Subscribers.xlsx") + openSheet = openFile.active # gets the active sheet + initialRow = 2 + emailAddress = input(str("What's the email address you would like to add?\nNew subscriber: ")) + + while openSheet.cell(row=initialRow, column=1).value is not None: # look for recipients on the excel sheet + if initialRow == 997: # statement to avoid reaching max depth + print("The maximum of recipients was exceeded! ") + break + else: + initialRow += 1 + + toString = 'A' + str(initialRow) + openSheet[toString] = emailAddress + openFile.save(filename) diff --git a/EmailSender/main.py b/EmailSender/main.py new file mode 100644 index 0000000..c897a87 --- /dev/null +++ b/EmailSender/main.py @@ -0,0 +1,46 @@ +from spammer import spammer # imports the function in spammer.py +from send_email import sendEmail # imports the function in send_email.py +from add_email import addSubscriber # imports the function in add_email.py +from quick_guide import quickGuide # imports the function in quick_guide.py +import time # imports time functions + + +def main(): + print("\n== Main Menu ==" + "\n1. Spammer" + "\n2. Send Email" + "\n3. Add subscriber" + "\n4. Quick Guide\n") + choice = str(input("Which option would you like to use?\nOption: ")) + print("\n") + if choice == "1": + spammer() + time.sleep(2) + print("\n") + main() + if choice == "2": + sendEmail() + time.sleep(2) + print("\n") + main() + if choice == "3": + addSubscriber() + time.sleep(2) + print("\n") + main() + if choice == "4": + quickGuide() + time.sleep(2) + print("\n") + main() + else: + print("Invalid choice.\nPlease try again!") + time.sleep(2) + main() + + return choice + + +if __name__ == '__main__': + mainMenu = main() + print(mainMenu) diff --git a/EmailSender/quick_guide.py b/EmailSender/quick_guide.py new file mode 100644 index 0000000..90e0d46 --- /dev/null +++ b/EmailSender/quick_guide.py @@ -0,0 +1,9 @@ +def quickGuide(): + print("Hello dear user, this is a quick guide on how to use the beta version of my email subscription/ spammer " + "bot.\nHere are the steps you will have to go through in order to work with my bot:\n\n->SETUP:\n1.Create " + "an Excel file named Subscribers.xlsx on the folder you saved the bot;\n2.Add up to 995 email addresses from " + "the cell A1 and below;\n3.Make sure you don't leave any blank cell in between email addresses or else it " + "won't be read.\n\n->OPTIONS:\n1.Spammer - Allows you to spam the email addresses on your excel sheet for " + "an amount of times of your own choice;\n2.Send email - Allows you to send an email with a subject and a " + "body to the emails on your Excel sheet;\n3.Add Subscriber - Type in the email address you wish to add to " + "the Excel spreadsheet.\n\nHope you enjoy it and make a good use of it!") diff --git a/EmailSender/send_email.py b/EmailSender/send_email.py new file mode 100644 index 0000000..31e9107 --- /dev/null +++ b/EmailSender/send_email.py @@ -0,0 +1,30 @@ +import openpyxl # import library to read excel files +import smtplib # library to login to gmail, send emails, etc... + + +def sendEmail(): + sender = " " # email address for sender + password = " " # password for sender + openFile = openpyxl.load_workbook("Subscribers.xlsx") + openSheet = openFile.active # gets the active sheet + recipientsList = [] + initialRow = 2 + recipient = openSheet.cell(row=initialRow, column=1).value + + while openSheet.cell(row=initialRow, column=1).value is not None: # look for recipients on the excel sheet + if initialRow == 997: # statement to avoid reaching max depth + print("The maximum of recipients was exceeded! ") + break + else: + initialRow += 1 + recipientsList.append(recipient) + + subject = str(input("What is the subject of the email?\nSubject: ")) + message = str(input("What is the body of your message?\nBody: ")) + + smtp_sever = smtplib.SMTP_SSL("smtp.gmail.com", 465) # sets the server and the port + smtp_sever.login(sender, password) # login to account with email and pw + content = "Subject: {}\n\n{}".format(subject, message) # formats the email + smtp_sever.sendmail(sender, recipient, content) # send message + + smtp_sever.close() # closes server/ disconnects diff --git a/EmailSender/spammer.py b/EmailSender/spammer.py new file mode 100644 index 0000000..31bf5fb --- /dev/null +++ b/EmailSender/spammer.py @@ -0,0 +1,45 @@ +import openpyxl # import library to read excel files +import smtplib # library to login to gmail, send emails, etc... +import time # imports time functions + + +def spammer(): + sender = " " # email address for sender + password = " " # password for sender + openFile = openpyxl.load_workbook("Subscribers.xlsx") + openSheet = openFile.active # gets the active sheet + recipientsList = [] + initialRow = 2 + + while openSheet.cell(row=initialRow, column=1).value is not None: + recipient = openSheet.cell(row=initialRow, column=1).value + if recipient is None: + print("No more emails addresses were found.\nPlease ensure that there's no blank cell in between email " + "addresses!") + break + elif initialRow == 997: + print("The maximum of recipients was exceeded! ") + break + else: + initialRow += 1 + recipientsList.append(recipient) + + subject = str(input("What is the subject of the email?\nSubject: ")) + message = str(input("What is the body of your message?\nBody: ")) + numberOfEmails = int(input("How many times do you want to spam this email?\n== Be aware the limit is 100 == " + "\nSpam number: ")) + + smtp_sever = smtplib.SMTP_SSL("smtp.gmail.com", 465) + smtp_sever.login(sender, password) + content = "Subject: {}\n\n{}".format(subject, message) + + if numberOfEmails > 995: + numberOfEmails = 995 + + while numberOfEmails > 0: + numberOfEmails -= 1 + for recipient in recipientsList: + time.sleep(5) # avoids server disconnection from gmail + smtp_sever.sendmail(sender, recipient, content) + + smtp_sever.close()