Verde Denim tdldev at
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

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:
        line = raw_input()
    except EOFError:
    if not line:
    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: <>

More information about the Python-list mailing list