Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Message-ID header in email when not set. #2915

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add Message-ID to HTTP_HEADER_FIELDNAME_MAP ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://en.wikipedia.org/wiki/Message-ID is not really related or used in HTTP.

auto uuid = Uuid();
slaff marked this conversation as resolved.
Show resolved Hide resolved
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
Loading