Skip to content

Instantly share code, notes, and snippets.

@davidthewatson
Created December 11, 2012 16:03
Show Gist options
  • Save davidthewatson/4259695 to your computer and use it in GitHub Desktop.
Save davidthewatson/4259695 to your computer and use it in GitHub Desktop.
sendmail from python
from email.mime.text import MIMEText
from subprocess import Popen, PIPE
msg = MIMEText("You don't have to have password access to someone's email account to send email as them.")
msg["From"] = "FirstName LastName <[email protected]>"
msg["To"] = "FirstName LastName <[email protected]>, FirstName LastName <[email protected]>"
msg["Subject"] = "This is the subject."
p = Popen(["/usr/sbin/sendmail", "-t"], stdin=PIPE)
p.communicate(msg.as_string())
@zackdouglas
Copy link

Sure, you don't, but it's a good idea to educate people on why not to: Do it too much, and your server is flagged for spammy behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment