From 78b6f7232af128cde421519c99e8cbb81b837f26 Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Mon, 27 Feb 2023 16:47:21 +0100 Subject: [PATCH] email: remove content headers of passed-in message The email has already been parsed according to the headers, but they are still present. However, signing or encrypting the email will change the content format, so remove any such headers before continuing. --- email/worker.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/email/worker.go b/email/worker.go index 881f9739d3534a34f2d055995602fcb5422741f9..288b3e0d528c5967200404969364083a275d9a5e 100644 --- a/email/worker.go +++ b/email/worker.go @@ -99,6 +99,11 @@ func EnqueueStd(ctx context.Context, header mail.Header, rcpts = append(rcpts, addr.Address) } + // Disallow content headers, signing/encrypting will change this + header.Del("Content-Transfer-Encoding") + header.Del("Content-Type") + header.Del("Content-Disposition") + if !header.Has("Message-Id") { header.GenerateMessageID() }