Created
May 7, 2013 17:18
-
-
Save chiiph/5534374 to your computer and use it in GitHub Desktop.
This file contains 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
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