Created
December 11, 2012 16:03
-
-
Save davidthewatson/4259695 to your computer and use it in GitHub Desktop.
sendmail from python
This file contains hidden or 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
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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.