New submission from DDarko: I'm trying to send an email as follows:
smtp = smtplib.SMTP(host, port=25) smtp.ehlo() smtp.sendmail(from_mail, to_mail, data) The last line / command calls the raise. I would like to know the reason why SMTP did not accept my email? In theory, enough to capture the exception. However, the exception of the last line returns: "smtplib.SMTPServerDisconnected: Connection unexpectedly closed" This is because the smtplib get replies in: http://hg.python.org/cpython/file/default/Lib/smtplib.py 767 (code, resp) = self.data(msg) Then performs: 769 self.rset() As a result, the SMTP server disconnects the client. And instead receive info with reason I have information about sudden disconnection. I do not think it should be reset, and if it is wrapped in a try. Working snippet: (code, resp) = self.data(msg) if code != 250: #self.rset() raise SMTPDataError(code, resp) #if we got here then somebody got our mail return senderrs This happens on servers mx.google.com ---------- components: Library (Lib) messages: 171029 nosy: DDarko priority: normal severity: normal status: open title: smtplib.SMTP().sendmail() and rset() type: behavior versions: Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16005> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com