how to send mail with python using SMTP ?

Daniel Fackrell unlearned at DELETETHIS.learn2think.org
Thu Aug 1 18:25:39 CEST 2002


"Alon" <alon_guy at hotmail.com> wrote in message
news:c2a441ad.0208010744.4d452b9a at posting.google.com...
> 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')


To me, it appears that you're not running sendmail on your system.  You can
either verify that an SMTP server is running on the local host, or you can
point it to an SMTP server provided by, e.g. your ISP.

--
Daniel Fackrell (unlearned at learn2think.org)
When we attempt the impossible, we can experience true growth.





More information about the Python-list mailing list