From ff2eb297c4372f2c7c797e617698d5748efcd5f4 Mon Sep 17 00:00:00 2001 From: "Ezenwanne I. Cosmas" Date: Fri, 13 Jan 2017 18:49:02 +0100 Subject: [PATCH] Caught SmtpClient::SendMessageTimeoutException In Smtp::quit, SmtpClient::SendMessageTimeoutException is caught and if still connected to the smtp server, manually close the connection. --- src/smtpclient.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/smtpclient.cpp b/src/smtpclient.cpp index 7370a78..af77207 100644 --- a/src/smtpclient.cpp +++ b/src/smtpclient.cpp @@ -420,7 +420,16 @@ bool SmtpClient::sendMail(MimeMessage& email) void SmtpClient::quit() { - sendMessage("QUIT"); + try + { + sendMessage("QUIT"); + } + catch(SmtpClient::SendMessageTimeoutException) + { + //Manually close the connection to the smtp server if message "QUIT" wasn't received by the smtp server + if(socket->state() == QAbstractSocket::ConnectedState || socket->state() == QAbstractSocket::ConnectingState || socket->state() == QAbstractSocket::HostLookupState) + socket->disconnectFromHost(); + } } /* [3] --- */