bluetiger9 / SmtpClient-for-Qt

An SMTP Client writen in C++ for Qt. Allows applications to send emails (MIME with text, html, attachments, inline files, etc.) via SMTP. Supports SSL and SMTP authentication.
https://github.com/bluetiger9/SmtpClient-for-Qt/wiki
GNU Lesser General Public License v2.1
456 stars 228 forks source link

Not able to connect to the internal smtp server #95

Closed vikasgrao2 closed 2 years ago

vikasgrao2 commented 5 years ago

Having the access to the smtp server from the internal network, it was not able to connect to the server, and the connectToHost() was returning false with an error code of ConnectionTimeoutError.

The return was from the below snippet if (!socket->waitForConnected(connectionTimeout)) { emit smtpError(ConnectionTimeoutError); return false; }

Tried with all type of Connections, Tcp, SSL and TLS. The same was able to connect to other smtp servers like gmail, yahoo etc. Also, the smtp server that is getting connection time out, is able to be telnet from the system.

Is there anything that is missing out ?

InikOfDoom commented 4 years ago

Late for the party but it might help others: I was tricked by the same issue by the company proxy.

smtpClient.getSocket()->setProxy(QNetworkProxy::NoProxy);

did the trick for me. This was revealed rather quickly after adding some oputput to the socket error handler:

void SmtpClient::socketError(QAbstractSocket::SocketError socketError) { qWarning()<<"Socket Error: "<errorString(); }

HTH!