Skip to content

Instantly share code, notes, and snippets.

@jiyeonseo
Created July 5, 2023 02:31
Show Gist options
  • Save jiyeonseo/b1abeaf19ded8ccaed4776dc0f35adf6 to your computer and use it in GitHub Desktop.
Save jiyeonseo/b1abeaf19ded8ccaed4776dc0f35adf6 to your computer and use it in GitHub Desktop.
simple test mail sender
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
# Email configuration
sender_email = "[email protected]"
receiver_email = "[email protected]"
password = "enter user password"
subject = "Test Email@!!@@@!"
body = "This is a test email."
# Create message object
message = MIMEMultipart()
message["From"] = sender_email
message["To"] = receiver_email
message["Subject"] = subject
# Add body to message
message.attach(MIMEText(body, "plain"))
# Create SMTP session
with smtplib.SMTP("smtp.gmail.com", 587) as server:
# Start TLS for security
server.starttls()
# Login to sender email account
server.login(sender_email, password)
# Send email
server.sendmail(sender_email, receiver_email, message.as_string())
# Done
print("DONE!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment