-
-
Save kmkmjhyiiiu/ec464d89e26c0376aed82892b5790d64 to your computer and use it in GitHub Desktop.
Testing SMTP server from command line using python
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
# skipped your comments for readability | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
me = "" | |
my_password = r"" | |
you = "" | |
msg = MIMEMultipart('alternative') | |
msg['Subject'] = "Alert" | |
msg['From'] = me | |
msg['To'] = you | |
html = '<html><body><p>Hi, I have the following alerts for you!</p></body></html>' | |
part2 = MIMEText(html, 'html') | |
msg.attach(part2) | |
# Send the message via gmail's regular server, over SSL - passwords are being sent, afterall | |
s = smtplib.SMTP_SSL('smtp.gmail.com') | |
# uncomment if interested in the actual smtp conversation | |
# s.set_debuglevel(1) | |
# do the smtp auth; sends ehlo if it hasn't been sent already | |
s.login(me, my_password) | |
s.sendmail(me, you, msg.as_string()) | |
s.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment