Skip to content

Instantly share code, notes, and snippets.

@dogukancagatay
Created April 7, 2021 15:43
Show Gist options
  • Save dogukancagatay/ce5c547c97afab017a9a41ecf4711338 to your computer and use it in GitHub Desktop.
Save dogukancagatay/ce5c547c97afab017a9a41ecf4711338 to your computer and use it in GitHub Desktop.
Send test e-mail with Python smtplib
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
s = smtplib.SMTP(host="localhost", port=25)
# s.starttls() # Enable if your mail server uses TLS
# s.login("[email protected]", "mysupersecretpassword") # Enable if using user authentication
msg = MIMEMultipart()
message = "This is a test message"
msg['From'] = "[email protected]"
msg['To'] = "[email protected]"
msg['Subject']="TEST e-mail"
msg.attach(MIMEText(message, "plain"))
s.send_message(msg)
del msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment