From fdb3662452dcb530963439b098a13816ef38ea6d Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Tue, 19 May 2026 14:59:00 +0200 Subject: [PATCH] email: properly set headers if no PGP configured If neither the instance nor the recipient has a PGP key, the codepath (correctly) sets the message body to the plain text but uses a fresh set of headers, so all configured headers get dropped, including subject and from. While the service is certainly intended to be run with PGP configured it makes sense to keep this option reasonably functional for testing and development purposes. This commit fixes the issue by initializing the header set to the already configured headers if neither encryption nor signing is used. --- email/worker.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/email/worker.go b/email/worker.go index 3e8874d22a8ca10c1632dd37b27ac1edbb41b495..8e7eb03543cdde3579a5933a13ade98b89f16847 100644 --- a/email/worker.go +++ b/email/worker.go @@ -144,13 +144,15 @@ func EnqueueStd(ctx context.Context, header mail.Header, } var ( - buf bytes.Buffer - cleartext io.WriteCloser + buf bytes.Buffer + cleartext io.WriteCloser + inlineHeader mail.Header ) if rcptKey != nil { cleartext, err = prepareEncrypted(rcptKey, header, &buf, queue.entity) } + // Fall back to unencrypted email if encryption did not work // TODO should we add the error message to the email? if rcptKey == nil || err != nil { @@ -167,10 +169,10 @@ func EnqueueStd(ctx context.Context, header mail.Header, } } else { cleartext = nopWriteCloser{&buf} + inlineHeader = header } } - var inlineHeader mail.Header inlineHeader.SetContentType("text/plain", map[string]string{ "charset": "UTF-8", "format": "flowed",