Skip to content

Instantly share code, notes, and snippets.

@madssj
Last active December 18, 2015 01:29
Show Gist options
  • Save madssj/5704552 to your computer and use it in GitHub Desktop.
Save madssj/5704552 to your computer and use it in GitHub Desktop.
def send_plain_mail(subject, body, from_mail, to):
import smtplib
from email.MIMEText import MIMEText
from email.Encoders import encode_quopri
msg = MIMEText(body, 'plain', 'iso-8859-1')
msg['Subject'] = subject
msg['From'] = from_mail
msg['To'] = to
s = smtplib.SMTP()
s.connect()
s.sendmail(from_mail, [to], msg.as_string())
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment