From cae7bf3316a8d3d612a0c278f78dae45d52fa786 Mon Sep 17 00:00:00 2001 From: slaff Date: Tue, 26 Nov 2024 12:54:36 +0100 Subject: [PATCH] Add Message-ID header in email when not set. (#2915) Google Mail and others started requesting Message-ID header to be present, otherwise messages are blocked/getting marked as spam. --- Sming/Components/Network/src/Network/SmtpClient.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sming/Components/Network/src/Network/SmtpClient.cpp b/Sming/Components/Network/src/Network/SmtpClient.cpp index 477436c6d5..0bad31c808 100644 --- a/Sming/Components/Network/src/Network/SmtpClient.cpp +++ b/Sming/Components/Network/src/Network/SmtpClient.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -296,6 +297,12 @@ void SmtpClient::sendMailHeaders(MailMessage* mail) mail->stream = std::make_unique(mail->stream.release()); } + if(!mail->headers.contains(F("Message-ID"))) { + 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;