views:

39

answers:

0

I am running Python 2.5 on Windows 7 x64 with smtp4dev running in the background. When I run the following script:

import smtplib
s=smtplib.SMTP('localhost',25)
tolist=['[email protected]']
msg='''
From: [email protected]
Subject: testin'...

This is a test '''
s.sendmail("[email protected]",tolist,msg)
s.quit()

After a 30-second timeout, I receive this error:

Traceback (most recent call last):
  File "testmail.py", line 9, in <module>
    s.sendmail("[email protected]",tolist,msg)
  File "C:\Python25\lib\smtplib.py", line 691, in sendmail
    self.rset()
  File "C:\Python25\lib\smtplib.py", line 453, in rset
    return self.docmd("rset")
  File "C:\Python25\lib\smtplib.py", line 378, in docmd
    return self.getreply()
  File "C:\Python25\lib\smtplib.py", line 355, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed

I have successfully received emails in smtp4dev using telnet localhost 25. Can anybody see what I'm missing?