smtp
Verde Denim
tdldev at gmail.com
Mon Aug 8 12:08:35 EDT 2011
I'm working on learning various aspects of Py coding, and happened to review
the smtplib docs this morning.
I entered the sample code from
http://www.python.org/doc//current/library/smtplib.html
import smtplib
def prompt(prompt):
return raw_input(prompt).strip()
fromaddr = prompt("From: ")toaddrs = prompt("To: ").split()print
"Enter message, end with ^D (Unix) or ^Z (Windows):"
# Add the From: and To: headers at the start!msg = ("From: %s\r\nTo: %s\r\n\r\n"
% (fromaddr, ", ".join(toaddrs)))while 1:
try:
line = raw_input()
except EOFError:
break
if not line:
break
msg = msg + line
print "Message length is " + repr(len(msg))
server = smtplib.SMTP('localhost')server.set_debuglevel(1)server.sendmail(fromaddr,
toaddrs, msg)server.quit()
and it returns -
"TypeError" with no other information...
It appears to be generated from the line
msg = ("From: %s\r\nTo: %s\r\n\r\n"
% (fromaddr, ", ".join(toaddrs)))
But I'm not sure why...
Any input is appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110808/68b8cdf8/attachment.html>
More information about the Python-list
mailing list