Inconsistent SMTP/Gmail connection drop

Astley Le Jasper astley.lejasper at gmail.com
Wed Aug 3 17:46:04 EDT 2011


I have a laptop that wakes up and then runs a script that collects
info and sends an email with a spreadsheet (zipped and about 350KB)
report to a number of people. However, every time I get the following
error:


File "/usr/lib/python2.7/smtplib.py", line 343, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")


- When I check the laptop and manually run the function that sends the
email and report, it works fine. I have never been able to replicate
the error when doing it manually.
- It can't be a problem with Gmail at that time in the morning or my
connection, because the script also sends me a copy of the log file
straight after, and that works.
- The same code has been working for years, it just that I have
recently rebuilt the machine so now it is using Python 2.7. I have
also change the references to use absolute file references, rather
than relative. I also have changed the code to run as root.
- I've checked the smtp debug report and everything seems ok. I just
never get the confirmation code (250) to say that it's completed.
- Even stranger ... it ran ok once. But I didn't change a thing and
the next day it wouldn't work.

The only thing I can think of is that when the file is transferred to
the reports directory, it somehow isn't been released quickly enough
and perhaps this is tripping up SMTP. But ... this is a bit of a guess
given I've tried to exhaust all the other options.

Any ideas?




More information about the Python-list mailing list