how to send mail with python using SMTP ?
Alon
alon_guy at hotmail.com
Thu Aug 1 11:44:10 EDT 2002
Hello,
Can you please guide me how to send mail with python using SMTP .
I've tried the code:
fromadd="gwarshavsky at globespanvirata.com"
toadd="gwarshavsky at globespanvirata.com"
msg=("From: %s\r\nTo: %s\r\n\r\n" % (fromadd, string.join(toadd, ",
"))) msg=msg+" test"
server=smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromadd,toadd,"test")
server.quit()
but the Python wrote:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "b_t_serv.py", line 390, in send_mail
server=smtplib.SMTP('localhost')
File "C:\guyw\Python22\lib\smtplib.py", line 234, in __init__
(code, msg) = self.connect(host, port)
File "C:\guyw\Python22\lib\smtplib.py", line 283, in connect
raise socket.error, msg
socket.error: (10061, 'Connection refused')
I'll appreciate you help.
Thanks, Guy.
More information about the Python-list
mailing list