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
449 stars 226 forks source link

2023 may 31 #138

Closed Edward-LeBlanc closed 1 year ago

Edward-LeBlanc commented 1 year ago

In all of the samples, the SmtpClient is deleted right after the quit() command, and the instance is not reused. The proposed changes implement the QUIT command fully and allow waiting for the server to close the connection. Critical variables are reset so that the connection can be reopened later.

The QTimer in SmtpClient::waitForEvent() was getting destroyed right after starting it, so that a timeout could never happen. Moving the instantiation to before the initialization scope solves that.

Flushing the socket stream after writing instead of before writing to it makes sure that the data get sent.