Created
November 4, 2011 21:11
-
-
Save hgdeoro/1340494 to your computer and use it in GitHub Desktop.
Simple Python SMTP client
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
# | |
# Minimal SMTP client | |
# Supports setting of TO, FROM, SUBJECT | |
# (multiple TOs must be separated by commas) | |
# Reads body from stdin | |
# | |
import smtplib | |
import os | |
import sys | |
msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (os.environ['FROM'], os.environ['TO'], os.environ['SUBJECT'])) | |
server = smtplib.SMTP(os.environ['SMTP']) | |
#server.set_debuglevel(1) | |
server.sendmail(os.environ['FROM'], os.environ['TO'].split(','), msg + sys.stdin.read()) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment