Skip to content

Instantly share code, notes, and snippets.

@lanbugs
Created June 22, 2018 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanbugs/1214d3e70fb1c9fa5c9c3de64f241a22 to your computer and use it in GitHub Desktop.
Save lanbugs/1214d3e70fb1c9fa5c9c3de64f241a22 to your computer and use it in GitHub Desktop.
Mini mailer in python to send mails via SMTP
#!/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