Message171029
| Author |
DDarko |
| Recipients |
DDarko |
| Date |
2012年09月23日.12:21:24 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1348402885.58.0.691449233826.issue16005@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|
History
|
|---|
| 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 |
|