From 315a8869a4b1fe6071933a6ffc37e8566bd7c914 Mon Sep 17 00:00:00 2001 From: anon Date: Thu, 18 Apr 2024 23:34:28 +0200 Subject: [PATCH] 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. --- email.d | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/email.d b/email.d index 9dd826f..e6095a4 100644 --- a/email.d +++ b/email.d @@ -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;