-
-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SMTP.quit() called when not connected #93
Comments
I think the problem manifests when the mail server drops the connection and smtplib detects this during a send or reply-reading. On detecting the problem, smtplib closes the connection and raises an exception (in send or getreply) and the Connection.exit() handler then tries to write a "quit" to the connection, which causes a new exception that masks the underlying error. |
Hi! Seems that the app closes the connection before end the sending so SMTPServerDisconnected: please run connect() first is raised I have some exim logs to ilustrate this problem @ http://pastebin.com/EPCcfj6e Hope this will help because I still have random errors Thanks! |
This issue should really be sorted by now, I included the required fix in the first comment (and justified it in the second). |
But is this pushed already? |
So, can you push the correction to pypi? |
There was another commit that silenes disconnection exceptions during quitting, but this one has a nice test case...
I'm not clear how this issue can happen. We don't call from flask import Flask
from flask_mail import Mail, Message
app = Flask(__name__)
app.config.update({
"MAIL_HOST": "127.0.0.1",
"MAIL_PORT": 1025,
})
mail = Mail(app)
with app.app_context():
with mail.connect() as c:
c.send(Message("test", sender="test", recipients=["test"])) |
Connection.exit() tries to call quit() even if there's no socket connection. "if self.host" should say "if self.host and getattr(self.host, 'sock', None)" to match the check in smtplib.SMTP.quit().
The text was updated successfully, but these errors were encountered: