From f8fc31a050e3531a171e43d7673c7020f25feeb6 Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Mon, 25 Nov 2024 14:26:21 +0100 Subject: [PATCH 1/3] 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..3e5aa14d8f 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"))) { + 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; From 8b7865ea6ac8535e9b6c850d56e61d81bd41b57c Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Mon, 25 Nov 2024 14:53:40 +0100 Subject: [PATCH 2/3] Fixe(s) suggested by Mikee. --- Sming/Components/Network/src/Network/SmtpClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sming/Components/Network/src/Network/SmtpClient.cpp b/Sming/Components/Network/src/Network/SmtpClient.cpp index 3e5aa14d8f..4cf2c9960b 100644 --- a/Sming/Components/Network/src/Network/SmtpClient.cpp +++ b/Sming/Components/Network/src/Network/SmtpClient.cpp @@ -298,7 +298,7 @@ void SmtpClient::sendMailHeaders(MailMessage* mail) } if(!mail->headers.contains(F("Message-ID"))) { - auto uuid = Uuid(); + Uuid uuid; uuid.generate(); mail->headers[F("Message-ID")] = "<" + uuid.toString() + "@" + url.Host + ">"; } From c45375b0d57c9b13d0b8e1321aa54529a4a9ab50 Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Tue, 26 Nov 2024 11:50:34 +0100 Subject: [PATCH 3/3] Fix cs. --- Sming/Components/Network/src/Network/SmtpClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sming/Components/Network/src/Network/SmtpClient.cpp b/Sming/Components/Network/src/Network/SmtpClient.cpp index 4cf2c9960b..0bad31c808 100644 --- a/Sming/Components/Network/src/Network/SmtpClient.cpp +++ b/Sming/Components/Network/src/Network/SmtpClient.cpp @@ -300,7 +300,7 @@ void SmtpClient::sendMailHeaders(MailMessage* mail) if(!mail->headers.contains(F("Message-ID"))) { Uuid uuid; uuid.generate(); - mail->headers[F("Message-ID")] = "<" + uuid.toString() + "@" + url.Host + ">"; + mail->headers[F("Message-ID")] = "<" + uuid.toString() + "@" + url.Host + ">"; } if(!mail->attachments.isEmpty()) {