diff --git a/src/base/net/smtp.cpp b/src/base/net/smtp.cpp index 75b0cb1bb..2507c5532 100644 --- a/src/base/net/smtp.cpp +++ b/src/base/net/smtp.cpp @@ -97,6 +97,13 @@ Smtp::Smtp(QObject *parent) , m_useSsl(false) , m_authType(AuthPlain) { + static bool needToRegisterMetaType = true; + + if (needToRegisterMetaType) { + qRegisterMetaType(); + needToRegisterMetaType = false; + } + #ifndef QT_NO_OPENSSL m_socket = new QSslSocket(this); #else @@ -105,6 +112,7 @@ Smtp::Smtp(QObject *parent) connect(m_socket, SIGNAL(readyRead()), SLOT(readyRead())); connect(m_socket, SIGNAL(disconnected()), SLOT(deleteLater())); + connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(error(QAbstractSocket::SocketError))); // Test hmacMD5 function (http://www.faqs.org/rfcs/rfc2202.html) Q_ASSERT(hmacMD5("Jefe", "what do ya want for nothing?").toHex() @@ -525,3 +533,11 @@ QString Smtp::getCurrentDateTime() const QString ret = weekDayStr + ", " + dayStr + " " + monthStr + " " + yearStr + " " + timeStr + " " + timeOffsetStr; return ret; } + +void Smtp::error(QAbstractSocket::SocketError socketError) +{ + // Getting a remote host closed error is apparently normal, even when successfully sending + // an email + if (socketError != QAbstractSocket::RemoteHostClosedError) + logError(m_socket->errorString()); +} diff --git a/src/base/net/smtp.h b/src/base/net/smtp.h index 0bd3cb489..da0d5a4e6 100644 --- a/src/base/net/smtp.h +++ b/src/base/net/smtp.h @@ -39,6 +39,8 @@ #include #include #include +#include +#include QT_BEGIN_NAMESPACE class QTextStream; @@ -64,6 +66,7 @@ namespace Net private slots: void readyRead(); + void error(QAbstractSocket::SocketError socketError); private: enum States @@ -123,4 +126,8 @@ namespace Net }; } +#ifndef QBT_USES_QT5 +Q_DECLARE_METATYPE(QAbstractSocket::SocketError) +#endif + #endif diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index 3777ef95e..6d434fb38 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -149,6 +149,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) #if defined(QT_NO_OPENSSL) m_ui->checkWebUiHttps->setVisible(false); + m_ui->checkSmtpSSL->setVisible(false); #endif #ifndef Q_OS_WIN