newbie: raise socket.error, msg in smtplib

Gerhard Haering gh at
Tue Apr 15 13:51:27 CEST 2003

Mark Carter wrote:
> I'm getting
> Traceback (most recent call last):
>   File "C:\My Documents\", line 26, in ?
>     s.connect()
>   File "C:\PYTHON22\lib\", line 283, in connect
>     raise socket.error, msg
> error: (10061, 'Connection refused')
> [...]
> s = smtplib.SMTP()

smtplib.SMTP is defined similar to:

class SMTP:
	def __init__(self, host="localhost", port=25)

So if you omit host and port, it tries to connect to the computer you're 
running the program from (, aka localhost on the default SMTP 
port - 25).

It seems you're not running an SMTP server on your box, so just specify 
a SMTP server you have access to.

-- Gerhard

More information about the Python-list mailing list