sending of mail (smtp) - connection refused - but smtp server is

Alex Hunsley lard at tardis.ed.ac.molar.uk
Tue Jun 29 16:41:03 CEST 2004


Peter Hansen wrote:
> Alex Hunsley wrote:
> 
>> I am failing with "connection refused" error, even though we 
>> definitely have an smtp server running on port 25!
> 
> ...
> 
>> any ideas what the problem could be? this usually happens when someone 
>> is not aware they have to run an SMTP server, but we do have one 
>> running, as can be seen above!
> 
> 
> Not sure, but please try this at the interactive prompt and report
> (or analyze) what it returns:
> 
>  >>> from socket import *
>  >>> getaddrinfo('192.168.1.105', 25, 0, SOCK_STREAM)
> 
> 
> This is something that smtplib.py is actually doing to get the
> host:port combination that it uses to connect.  It seems that
> the only possible source for the failure you see is if it
> does not return the expected values.
> 
> -Peter

Hi Peter
when I run the above interactively, I get:

[(2, 1, 6, '', ('192.168.1.105', 25))]

I've just discovered something interesting.
If I completely miss out connect() and close(), it works!
i.e. my code now reads:

     s = smtplib.SMTP('192.168.1.105')
     #s.connect()
     s.sendmail(me, [you], msg.as_string())
     #s.close()


and this works! Is it a bad state of affairs to leave things in?
thanks
alex






More information about the Python-list mailing list