Skip to content

Instantly share code, notes, and snippets.

@chiiph
Created May 7, 2013 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiiph/5534374 to your computer and use it in GitHub Desktop.
Save chiiph/5534374 to your computer and use it in GitHub Desktop.
import sys
import telnetlib
if __name__ == "__main__":
mail = {
"from": sys.argv[1],
"to": sys.argv[2],
"subject": sys.argv[3],
"msg": sys.argv[4]
}
tn = telnetlib.Telnet()
tn.open("localhost", 25)
print tn.read_some()
cmds = [
"ehlo localhost",
"mail from: %s" % (mail["from"],),
"rcpt to: %s" % (mail["to"],),
"data",
"Subject: %s\n%s\n." % (mail["subject"], mail["msg"]),
"quit"
]
for cmd in cmds:
tn.write(cmd + "\n")
print tn.read_some()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment