Skip to content

Instantly share code, notes, and snippets.

@hgdeoro
Created November 4, 2011 21:11
Show Gist options
  • Save hgdeoro/1340494 to your computer and use it in GitHub Desktop.
Save hgdeoro/1340494 to your computer and use it in GitHub Desktop.
Simple Python SMTP client
#
# 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