cutelyst / simple-mail

An SMTP library written in C++ for Qt. Allows applications to send emails (MIME with text, html, attachments, inline files, etc.) via SMTP. Supports SSL and SMTP authentication.
GNU Lesser General Public License v2.1
213 stars 64 forks source link

Async-Problem and possible fix #82

Closed ix07 closed 1 year ago

ix07 commented 2 years ago

Hi.

First of all - thank you for making "simple-mail".

We experienced some problems with the async-version (the sync version worked without that problem!) and a colleague of mine investigated. He said that he was able to fix the problem by adding a line containing "\r\n.\r\n" to a mime-part.

The RFC specification seems to confirm that a mail must be terminated like that.

https://www.rfc-editor.org/rfc/rfc5321#section-4.5.2

I didn't work on the problem myself and don't know much about SMTP, so sorry for being a little vague on details (if necessary I can ask for more information). But I thought I should at least bring this to your attention.

Attached to this file you will find a patch file.

Thanks.

simplemail_patch.txt

joshorenberg commented 2 years ago

Thanks ix07. I applied the patch but the async code still does nothing. Any ideas what might be wrong?

RaphGava commented 2 years ago

Hi.

I confirm the issue (mail not send due to missing "\r\n.\r\n" to finish the data of a DATA command).

Nevertheless i think we may not change the write method of MimeMultipart (since it is used in the sync version too), or SenderPrivate::sendMail as to be modified too (too avoid the second dot line).

Another (not really beautiful) solution should be to add the dot line in the lambda function of ServerPrivate::createSocket(), line 293 of server.cpp :

- if (cont.msg.write(socket)) {
+ if (cont.msg.write(socket) && socket->write((QByteArrayLiteral("\r\n.\r\n")))) {
dantti commented 1 year ago

MR that fixes this was merged