Created
June 22, 2018 22:20
-
-
Save lanbugs/1214d3e70fb1c9fa5c9c3de64f241a22 to your computer and use it in GitHub Desktop.
Mini mailer in python to send mails via SMTP
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import smtplib | |
from email.mime.text import MIMEText | |
def postmaster(mfrom, mto, msubject, message, smtphost): | |
msg = MIMEText(message.encode("utf-8")) | |
msg['Subject'] = msubject | |
msg['From'] = mfrom | |
msg['To'] = mto | |
s = smtplib.SMTP(smtphost) | |
s.sendmail(msg['From'], msg['To'], msg.as_string()) | |
s.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment