Explicitly state that the text/html body isn't transfer-encoded

I'm not sure this is important, but thunderbird does it too, so it can't
hurt.

Relevant: RFC 2045 Sec. 6.4:
>The Content-Transfer-Encoding values "7bit", "8bit", and "binary" all
>mean that the identity (i.e. NO) encoding transformation has been
>performed.  As such, they serve simply as indicators of the domain of
>the body data, and provide useful information about the sort of
>encoding that might be needed for transmission in a given transport
>system.  The terms "7bit data", "8bit data", and "binary data" are
>all defined in Section 2.
This commit is contained in:
anon 2024-04-18 23:34:28 +02:00
parent dc2821ceab
commit 315a8869a4
1 changed files with 9 additions and 3 deletions

12
email.d
View File

@ -189,13 +189,14 @@ class EmailMessage {
{
MimeContainer mimeMessage;
enum NO_TRANSFER_ENCODING = "Content-Transfer-Encoding: 8bit";
if(isHtml) {
auto alternative = new MimeContainer("multipart/alternative");
alternative.stuff ~= new MimeContainer("text/plain; charset=UTF-8", textBody);
alternative.stuff ~= new MimeContainer("text/html; charset=UTF-8", htmlBody);
alternative.stuff ~= new MimeContainer("text/plain; charset=UTF-8", textBody).with_header(NO_TRANSFER_ENCODING);
alternative.stuff ~= new MimeContainer("text/html; charset=UTF-8", htmlBody).with_header(NO_TRANSFER_ENCODING);
mimeMessage = alternative;
} else {
mimeMessage = new MimeContainer("text/plain; charset=UTF-8", textBody);
mimeMessage = new MimeContainer("text/plain; charset=UTF-8", textBody).with_header(NO_TRANSFER_ENCODING);
}
top = mimeMessage;
}
@ -1153,6 +1154,11 @@ immutable(ubyte)[] decodeQuotedPrintable(string text) {
return ret;
}
/// Add header UFCS helper
auto with_header(MimeContainer container, string header){
container.headers ~= header;
return container;
}
/// Base64 range encoder UFCS helper.
alias base64encode = Base64.encoder;