epcim
10/21/2015 - 11:38 AM

python-mail-script.py.howto.md

#!/bin/env python

import smtplib

SERVER = "localhost"

FROM = "buggers@myorg.net" TO = ["user@example.com"] # must be a list

SUBJECT = "Hello!"

TEXT = "This message was sent with Python's smtplib."

Prepare actual message

message = """
From: %s To: %s Subject: %s

%s """ % (FROM, ", ".join(TO), SUBJECT, TEXT)

Send the mail

server = smtplib.SMTP(SERVER) server.sendmail(FROM, TO, message) server.quit()