Created
March 13, 2024 03:51
-
-
Save mraza007/daa95799efe7586b4f6c7d9bbf0d9d87 to your computer and use it in GitHub Desktop.
A simple script which allows you send email (Written for a blog)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "[email protected]" | |
receiver_email = "[email protected]" | |
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