intermittent smtp module problems (with sendmail) in python 2.2.1
Christopher T King
squirrel at WPI.EDU
Wed Aug 4 14:45:50 EDT 2004
On 4 Aug 2004, Karl Ehr wrote:
> I have written the following simple program to monitor a single URL,
> and notify me via email whenever this URL changes. Intermittently,
> I raise the following exception:
>
> smtplib.SMTPServerDisconnected: Connection unexpectedly closed
This is probably happening because of a timeout on the SMTP server. Try
moving this line:
> server = smtplib.SMTP('localhost') # server to relay smtp through for
To right in front of where you use it:
> server.set_debuglevel(1)
> server.sendmail(sourceAddress, emailAddress, message)
> server.quit()
the SMTP() constructor doesn't just set up a connection (and open it on
.sendmail()); it opens the connection when it's called and leaves it open
until you call .quit() (or delete the object).
More information about the Python-list
mailing list