how to send mail with python using SMTP ?
DIG
dig.list at telkel.net
Thu Aug 1 19:12:33 EDT 2002
Hi, Alon !
There is nothing wrong with your code -- it worked for me a minute ago. And I should tell you, the output is rather verbose.
You may want to check if your MTA (Mail Transport Agent) is up and running. For example, like this (from shell):
user at hostname:~$ telnet localhost smtp
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 your-hostname ESMTP Sendmail X.Y.Z; Thu, 1 Aug 2002 17:48:48 -0500
^^^
If you do not see ``220'', then something is wrong with your MTA.
(To quit telnet, you should do ^] (Ctrl+]), and then ^D (Ctrl+D)
On Thu, Aug 01, 2002 at 08:44:10AM -0700, Alon wrote:
> 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.
Regards,
--
DIG (Dmitri I GOULIAEV)
More information about the Python-list
mailing list