Skip to content

Instantly share code, notes, and snippets.

@SergSlon
Created January 20, 2015 08:38
Show Gist options
  • Select an option

  • Save SergSlon/0d7efec43fffc97948c1 to your computer and use it in GitHub Desktop.

Select an option

Save SergSlon/0d7efec43fffc97948c1 to your computer and use it in GitHub Desktop.
from email.mime.text import MIMEText
from subprocess import Popen, PIPE
msg = MIMEText("Here is the body of my message")
msg["From"] = "me@example.com"
msg["To"] = "you@example.com"
msg["Subject"] = "This is the subject."
p = Popen(["/usr/sbin/sendmail", "-t"], stdin=PIPE)
p.communicate(msg.as_string())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment