Message171029
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 |
|
Date |
User |
Action |
Args |
2012-09-23 12:21:25 | DDarko | set | recipients:
+ DDarko |
2012-09-23 12:21:25 | DDarko | set | messageid: <1348402885.58.0.691449233826.issue16005@psf.upfronthosting.co.za> |
2012-09-23 12:21:25 | DDarko | link | issue16005 messages |
2012-09-23 12:21:24 | DDarko | create | |
|