sending of mail (smtp) - connection refused - but smtp server is running!
Alex Hunsley
lard at tardis.ed.ac.molar.uk
Tue Jun 29 10:26:41 EDT 2004
I am using the smtp module to send emails via a local SMTP server on our network.
I am failing with "connection refused" error, even though we definitely have an
smtp server running on port 25!
the code is like this:
me = 'ahunsley at companyname.com'
you = 'someonelse at companyname.com'
msg['Subject'] = '*** alert'
msg['From'] = me
msg['To'] = you
s = smtplib.SMTP('192.168.1.105')
s.connect()
s.sendmail(me, [you], msg.as_string())
s.close()
print "Email sent."
When I run this code, I get:
Traceback (most recent call last):
File "C:\Python23\check.py", line 58, in -toplevel-
s.connect()
File "C:\Python23\lib\smtplib.py", line 302, in connect
raise socket.error, msg
error: (10061, 'Connection refused')
here's me verifying that SMTP server is indeed alive at port 25 on my local
network:
$ telnet 192.168.1.105 25
Trying 192.168.1.105...
Connected to 192.168.1.105.
Escape character is '^]'.
220 grain.companyname.com ESMTP Server FTGate
helo
250 grain.companyname.com
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!
thanks
alex
More information about the Python-list
mailing list