Skip to content

Instantly share code, notes, and snippets.

@samduy
Created December 31, 2017 13:04
Show Gist options
  • Save samduy/2b15ef5746099b2447e90bdaf75a9e3b to your computer and use it in GitHub Desktop.
Save samduy/2b15ef5746099b2447e90bdaf75a9e3b to your computer and use it in GitHub Desktop.
Python Email Sender (sendmail must be installed)
#!/usr/bin/python
import smtplib, string
import os, time
os.system("/etc/init.d/sendmail start")
time.sleep(4)
HOST = "localhost"
SUBJECT = "Email from spoofed sender"
TO = "[email protected]"
FROM = "[email protected]"
TEXT = "Message Body"
BODY = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT,
"",
TEXT
), "\r\n")
server = smtplib.SMTP(HOST)
server.sendmail(FROM, [TO], BODY)
server.quit()
time.sleep(4)
os.system("/etc/init.d/sendmail stop")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment