Skip to content

Instantly share code, notes, and snippets.

@mraza007
Created March 13, 2024 03:51
Show Gist options
  • Save mraza007/daa95799efe7586b4f6c7d9bbf0d9d87 to your computer and use it in GitHub Desktop.
Save mraza007/daa95799efe7586b4f6c7d9bbf0d9d87 to your computer and use it in GitHub Desktop.
A simple script which allows you send email (Written for a blog)
import smtplib
from email.mime.text import MIMEText
# Set up the email content
subject = "Test Email"
body = "This is a test email\n Hello World"
sender_email = "testing_email@xyz.com"
receiver_email = "recipient_test@abc.com"
message = MIMEText(body)
message["Subject"] = subject
message["From"] = sender_email
message["To"] = receiver_email
# Connect to the local SMTP server
server = smtplib.SMTP("localhost", 1025)
# Send the email
server.sendmail(sender_email, [receiver_email], message.as_string())
# Disconnect from the server
server.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment