New submission from Mark Sapiro <m...@msapiro.net>: RFC821 upon which smtplib was originally based does not define a 421 status code and implies the server should only disconnect in response to a QUIT command.
Subsequent extensions in RFC2821 (and now RFC5321) define situations under which the server may return a 421 status and disconnect. This leads to the following problem. An smtplib.SMTP() instance is created and its sendmail() method is called with a list of recipients which contains several invalid, local addresses. sendmail() processes the recipient list, calling the rcpt() method for each. Some of these may be accepted with a 250 or 251 status and some may be rejected with a 550 or other status. The rejects are kept in a dictionary to be eventually returned as the sendmail() result. However, with the Postfix server at least, after 20 rejects, the server sends a 421 Too many errors reply and disconnects, but sendmail continues to process and this results in raising SMTPServerDisconnected("Connection unexpectedly closed") and the response dictionary containing the invalid addresses and their responses is lost. The caller may see the exception as retryable and may retry the send after some delay, but since the caller has received no information about the invalid addresses, it sends the same recipient list and the scenario repeats. ---------- components: Library (Lib) messages: 85666 nosy: msapiro severity: normal status: open title: smtplib gets out of sync if server returns a 421 status type: behavior versions: Python 2.4, Python 2.5, Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5713> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com