Support for sending reports via SMTP
[urlwatch.git] / lib / urlwatch / mailer.py
blobff6adc3a7c572c8c28136a7234173c8b19d44504
2 import smtplib
3 from email.mime.text import MIMEText
5 def send(smtp_server, from_email, to_email, subject, body):
6 msg = MIMEText(body, 'plain', 'utf_8')
7 msg['Subject'] = subject
8 msg['From'] = from_email
9 msg['To'] = to_email
11 s = smtplib.SMTP()
12 s.connect(smtp_server, 25)
13 s.sendmail(from_email, [to_email], msg.as_string())
14 s.quit()