Skip to content

Commit

Permalink
Google Mail and others started requesting Message-ID header to be pre…
Browse files Browse the repository at this point in the history
…sent, otherwise messages are blocked/getting marked as spam.
  • Loading branch information
slav-at-attachix committed Nov 25, 2024
1 parent 502e304 commit f8fc31a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sming/Components/Network/src/Network/SmtpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <Data/Stream/QuotedPrintableOutputStream.h>
#include <Data/Stream/Base64OutputStream.h>
#include <Data/HexString.h>
#include <Data/Uuid.h>
#include <Crypto/Md5.h>
#include <Network/Ssl/Factory.h>

Expand Down Expand Up @@ -296,6 +297,12 @@ void SmtpClient::sendMailHeaders(MailMessage* mail)
mail->stream = std::make_unique<QuotedPrintableOutputStream>(mail->stream.release());
}

if(!mail->headers.contains(F("Message-ID"))) {
auto uuid = Uuid();
uuid.generate();
mail->headers[F("Message-ID")] = "<" + uuid.toString() + "@" + url.Host + ">";
}

if(!mail->attachments.isEmpty()) {
MultipartStream* mStream = new MultipartStream(MultipartStream::Producer(&SmtpClient::multipartProducer, this));
MultipartStream::BodyPart text;
Expand Down

0 comments on commit f8fc31a

Please sign in to comment.