hpcugent/vsc-base — pull request #81 by itkovian (2013-09-26 15:25:15+00:00)
Title: Fix sending mail through non-default mail hosts

connect() borks when run twice:

~~~~
In [2]: import smtplib

In [3]: s = smtplib.SMTP("smtp.ugent.be")

In [4]: s.connect()
---------------------------------------------------------------------------
error Traceback (most recent call last)
in ()
----> 1 s.connect()

/usr/lib64/python2.6/smtplib.pyc in connect(self, host, port)
293 if not port: port = self.default_port
294 if self.debuglevel > 0: print>>stderr, 'connect:', (host, port)
--> 295 self.sock = self._get_socket(host, port, self.timeout)
296 (code, msg) = self.getreply()
297 if self.debuglevel > 0: print>>stderr, "connect:", msg

/usr/lib64/python2.6/smtplib.pyc in _get_socket(self, port, host, timeout)
271 # and just alter the socket connection bit.
272 if self.debuglevel > 0: print>>stderr, 'connect:', (host, port)
--> 273 return socket.create_connection((port, host), timeout)
274
275 def connect(self, host='localhost', port = 0):

/usr/lib64/python2.6/socket.pyc in create_connection(address, timeout)
565 sock.close()
566
--> 567 raise error, msg

error: [Errno 111] Connection refused
~~~~