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

Newlines aren't sent #161

Closed aiphae closed 1 month ago

aiphae commented 1 month ago

When adding text with newline characters (\n) to the message, they don't actually make new lines in the sent email.

I tried replacing them with <br /> and other stuff but without success.

MimeText *text = new MimeText();
text->setText(email.getBody());
message.addPart(text);
mozhongzhou commented 1 month ago

自动回复:已收到您的邮件

bluetiger9 commented 1 month ago

Hi! :slightly_smiling_face:

Using newlines (\n) with MimeText should work fine. You can take a look at demo1.cpp for a working example.

If this does not works with a particular email provider, I would try two things:

  1. Use win style newlines (\r\n)
  2. Switch to HTML content. For this use MimeHtml instead of MimeText. See demo4.cpp for more details.

Thanks!