knadh / listmonk

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
https://listmonk.app
GNU Affero General Public License v3.0
14.6k stars 1.34k forks source link

Bad case for MIME-Version header #1349

Closed ldidry closed 1 year ago

ldidry commented 1 year ago

Version:

Description of the bug and steps to reproduce: The MIME-Version header is written as Mime-Version and that triggers a check on Rspamd (see here).

It doesn’t add a big spam-score (juste 0.5) but it could be avoided.

Indeed, the RFC which introduced the header use the upper-case version.

I couldn’t find where the header is added in listmonk code, so, sorry, I can’t produce a PR.

knadh commented 1 year ago

Did some digging and RFC 5322 (supersedes 2045) specifies that headers are case insensitive: https://stackoverflow.com/questions/6143549/are-email-headers-case-sensitive

In addition, unfortunately, Go's built in textproto.MIMEHeader{} automatically changes the case of all header keys that are set.

ldidry commented 1 year ago

Did some digging and RFC 5322 (supersedes 2045) specifies that headers are case insensitive

I was guessing something like that.

For people who see this issue: you can rewrite the header with Postfix.

apt install postfix-pcre
systemctl restart postfix

In /etc/postfix/main.cf:

# Header rewriting
header_checks = pcre:/etc/postfix/header_checks

In /etc/postfix/header_checks:

/^Mime-(Version:.*)/i REPLACE MIME-$1

As the header case is something normally harmless and as the "problem" comes from Go itself, I close the issue.