SimpleSmtp_SSL_QT5
SimpleSmtp_SSL_QT5 copied to clipboard
Sending mail via smtp over ssl produces error message
Hi there
I am sucessfully using the Simple Smtp SSL code with QT5. It works great, the email goes through and everything seems fine, but I get the following error message:
qt.network.ssl: QSslSocket::startClientEncryption: cannot start handshake on non-plain connection
When I check, if the socket ist encrypted socket->isEncrypted()
it gives a positive result.
Does this seem familiar to anyone or am I chasing ghosts unnecessarily?
Is it because we open the socket already encrypted and then the command socket->startClientEncryption()
is superfluous?
Thank you all in advance!
// TERMINAL
Init STATE ------------------------------
readyRead
Server response code: "250"
Server response: "250-smtp.mailserver.com\r\n250-SIZE 75000000\r\n250-AUTH PLAIN LOGIN\r\n250-AUTH=PLAIN LOGIN\r\n250 ENHANCEDSTATUSCODES\r\n"
Handshake STATE --------------------------
qt.network.ssl: QSslSocket::startClientEncryption: cannot start handshake on non-plain connection
is encrypted 1? :: true
"Unknown Error"
is encrypted 2? :: true
readyRead
Server response code: "250"
Server response: "250-smtp.mailserver.com\r\n250-SIZE 75000000\r\n250-AUTH PLAIN LOGIN\r\n250-AUTH=PLAIN LOGIN\r\n250 ENHANCEDSTATUSCODES\r\n"
// C++
void Smtp::sendMail(){
...
this->from = from;
rcpt = to;
state = Init;
// ---- Change for SSL ---------------------------------------
socket->connectToHostEncrypted(host, port);
...
}
void Smtp::readyRead(){
...
else if (state == HandShake && responseLine == "250")
{
qDebug() << "Handshake STATE --------------------------\r";
qDebug() << "is encrypted 1? :: " << socket->isEncrypted();
socket->startClientEncryption();
if(!socket->waitForEncrypted(timeout))
{
qDebug() << socket->errorString();
state = Close;
}
//Send EHLO once again but now encrypted
*t << "EHLO localhost" << "\r\n";
t->flush();
state = Auth;
qDebug() << "is encrypted 2? :: " << socket->isEncrypted();
}