SMTP problem

Joacim Löwgren fire at netlimit.com
Mon Jul 19 17:06:21 EDT 1999


Hi,

I copied this straight from the Python SMTP example, however it doesn't seem
it's working. I'm not quite sure what ^D does and if it is different on
Unix/Windows as I think this is the problem with the script.

_________________________________

import string, sys
import smtplib

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 = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()






More information about the Python-list mailing list