import rfc822, string, sys def prompt(prompt): sys.stdout.write(prompt + ": ") return string.strip(sys.stdin.readline()) fromaddr = prompt("From") toaddrs = string.splitfields(prompt("To"), ',') print "Enter message, end with ^D:" msg = '' while 1: line = sys.stdin.readline() if not line: break msg = msg + line print "Message length is " + `len(msg)` server = SMTP('localhost') server.set_debuglevel(1) server.sendmail(fromaddr, toaddrs, msg) server.quit()
See Also:
RFC 821, Simple Mail Transfer Protocol. Available online at http://info.internet.isi.edu/in-notes/rfc/files/rfc821.txt.
RFC 1869, SMTP Service Extensions. Available online at http://info.internet.isi.edu/in-notes/rfc/files/rfc1869.txt.