Skip to content

Instantly share code, notes, and snippets.

@saicologic
Created February 3, 2011 10:29
Show Gist options
  • Save saicologic/809319 to your computer and use it in GitHub Desktop.
Save saicologic/809319 to your computer and use it in GitHub Desktop.
import shlex
from eventlet.green import subprocess
mail = {}
mail['from'] = 'yourname@example.com'
mail['to'] = 'yourname@example.com'
mail['subject'] = 'test mail'
mail['body'] = 'test'
command_line = 'echo "From: <%s>\nTo: <%s>\nSubject:%s\n%s"' % (mail['from'],mail['to'],mail['subject'],mail['body'])
args = shlex.split(command_line)
p1 = subprocess.Popen(args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
command_line = '/usr/sbin/sendmail -t %s' % mail['to']
args = shlex.split(command_line)
subprocess.Popen(args, stdin=p1.stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment