Ubuntu Email Client

Download this code and run it using python3 with Ubuntu terminal. MAKE SURE YOU HAVE PYTHON3 INSTALLED. How to run (example): python3 email-snoop-dogg.py Btw this was AI generated lol but I checked and it works.

Remember, at the end of the email body, on its own line, type End, CASE SENSITIVE.

#!/usr/bin/env python3

import smtplib

from email.message import EmailMessage


def send_email(

    smtp_host,

    smtp_port,

    smtp_user,

    smtp_pass,

    from_addr,

    to_addr,

    subject,

    body,

    use_ssl=False

):

    msg = EmailMessage()

    msg["From"] = from_addr

    msg["To"] = to_addr

    msg["Subject"] = subject

    msg.set_content(body)


    if use_ssl:

        with smtplib.SMTP_SSL(smtp_host, smtp_port) as server:

            server.set_debuglevel(1)  # debug info

            server.login(smtp_user, smtp_pass)

            server.send_message(msg)

    else:

        with smtplib.SMTP(smtp_host, smtp_port) as server:

            server.set_debuglevel(1)  # debug info

            server.starttls()

            server.login(smtp_user, smtp_pass)

            server.send_message(msg)


    print("✅ Email sent successfully!")


if __name__ == "__main__":

    print("=== Simple SMTP Email Sender ===")

    smtp_host = input("SMTP host (e.g., smtp.gmail.com): ").strip()

    smtp_port = int(input("SMTP port (e.g., 587 or 465): ").strip())

    smtp_user = input("SMTP username (email): ").strip()

    smtp_pass = input("SMTP password or app password: ").strip()

    from_addr = input("From: ").strip()

    to_addr = input("To: ").strip()

    subject = input("Subject: ").strip()


    print("Enter message body (type 'End' on its own line to finish):")


    # ✅ Fix: use readline loop that ends immediately on "End"

    body_lines = []

    while True:

        line = input()

        if line.strip() == "End":

            break

        body_lines.append(line)

    body = "\n".join(body_lines)


    use_ssl = smtp_port == 465


    try:

        send_email(

            smtp_host,

            smtp_port,

            smtp_user,

            smtp_pass,

            from_addr,

            to_addr,

            subject,

            body,

            use_ssl

        )

    except Exception as e:

        print("❌ Failed to send email:", e)