smtp

Chris Angelico rosuav at gmail.com
Mon Aug 8 13:07:50 EDT 2011


On Mon, Aug 8, 2011 at 5:45 PM, Verde Denim <tdldev at gmail.com> wrote:
> I'm running 2.6.5 on a debian base...
> It didn't seem to matter what is input -
> I tried using a single recipient as well as multiples (separated by comma).

Since the recipient list is divided using split(), you should separate
multiple addresses with spaces. However, that won't cause your
problem.

I copied and pasted your exact code and tried it on three different
versions. Obviously Python 3 didn't like it (print statements). Python
2.4.5 failed on importing _socket, so I assume there's a minimum
version required. But 2.6.5 worked fine:


From: foo at bar
To: asdf at qwer
Enter message, end with ^D (Unix) or ^Z (Windows):
zxcvaasdf
ssdfzxcv
^Z
Message length is 49
Traceback (most recent call last):
  File "1test.py", line 24, in <module>
    server = smtplib.SMTP('localhost')
  File "C:\Python26\lib\smtplib.py", line 239, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Python26\lib\smtplib.py", line 295, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Python26\lib\smtplib.py", line 273, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "C:\Python26\lib\socket.py", line 514, in create_connection
    raise error, msg
socket.error: [Errno 10061] No connection could be made because the target machi
ne actively refused it

C:\>

I don't have an SMTP server running on localhost, but the script
worked fine. Can you quote a failing traceback please? It might be
instructive.

ChrisA



More information about the Python-list mailing list