Created
April 7, 2021 15:43
-
-
Save dogukancagatay/ce5c547c97afab017a9a41ecf4711338 to your computer and use it in GitHub Desktop.
Send test e-mail with Python smtplib
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.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