~bigbes/core-go

fdb3662452dcb530963439b098a13816ef38ea6d — Conrad Hoffmann 2 months ago ff38670
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.
1 files changed, 5 insertions(+), 3 deletions(-)

M email/worker.go
M email/worker.go => email/worker.go +5 -3
@@ 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",