Skip to content

Commit

Permalink
Add Message-ID header in email when not set. (#2915)
Browse files Browse the repository at this point in the history
Google Mail and others started requesting Message-ID header to be present, otherwise messages are blocked/getting marked as spam.
  • Loading branch information
slaff authored Nov 26, 2024
1 parent 7b3ef4f commit cae7bf3
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"))) {
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 cae7bf3

Please sign in to comment.