Greetings!
I'm writing here because, apparently, in 2021, there is still no other
way to report bugs or suggest features for Postifx. That's a bummer, but
please let me get to the point.
I've been setting up a personal mailserver using Postfix, and while I
don't have a lot of experience in Linux system administration and doing
things the "UNIX way" in general, so far I've found Postfix to be highly
configurable, and after extensively studying the manuals I've been able
to make it behave almost exactly as I wanted it to.
The problem is, however, that for people like me, there is always one or
two things that look so trivial, and they seem quite easy to do, but you
keep looking and looking and still can't find a way. It is in no way
essential for the server's operation but for completeness' sake I'd
really love to be able to do it one day.
What I'm talking about is rewriting the MAILER-DAEMON address. You'd ask
"why?", and here is the answer:
1. You probably don't like when people shout at you, right? Well,
all-caps looks a lot like someone's shouting at you. It'd look better if
it were all-lowercase.
2. While the above is mostly for aesthetical reasons, there is one other
thing: the templates for mailer-daemon messages have obsolete "From" and
"To" header formats, e.g.:
From: mailer-dae...@mydomain.com (Mail Delivery System)
To: postmas...@mydomain.com (Postmaster)
This appears to be the legacy RFC5322 header format (see
https://github.com/roundcube/roundcubemail/issues/5402). I'm not very
well versed in the RFC stuff, but what I can say for sure is that so far
I've ONLY seen this format in these templates, and nowhere else. It
looks like some email clients (like Roundcube, see the link above) do
not handle this format very well, probably for the reason that it's
barely used nowadays, if at all.
What's most problematic is that while both issues #1 and #2 can be
worked around for SOME templates, there appear to be a number of
hard-coded templates that cannot be changed without recompiling Postfix.
I understand that I can make changes to the source code and recompile
the program, but even if I am able to accomplish this, it would only be
half of the job done, if not even less than that. I'd also have to
arrange a process to create packages in the appropriate format for my OS
distribution and keep them updated. I'm afraid this would be very
difficult and extremely time-consuming for me, since like I said before,
I have only basic experience in Linux administration.
OK, let me get back to the point. As I've already said before, there are
some workarounds to issues #1 and #2, but they don't solve the cause,
only the symptom. For example, the MAILER-DAEMON address and the header
format can be fixed for bounce template notifications by introducing the
following configuration:
internal_mail_filter_classes = bounce
header_checks = pcre:${config_directory}/bounce_header_checks
/etc/postfix/bounce_header_checks content:
/^From:\s+MAILER-DAEMON\s+\((.+)\)\s*$/ REPLACE From: "$1"
<mailer-daemon>
(NB: it is most optimal to assign these checks to a separate cleanup
service used by bounce, defer, and trace so that other mail is not
affected.)
It can also be worked around with bounce_template_file. However,
_neither_ of these methods are applicable to some postmaster
notifications, for example, those generated with "notify_classes =
protocol" by smtp and smtpd services. The postconf(5) manual says that
postmaster notifications generated by smtp and smtpd _can_ be inspected
by adding "notify" to "internal_mail_filter_classes". Unfortunately,
while it does seem to enable DKIM signing for them (via the milter
application that I've configured), it still does not apply any header
checks to them. Frankly speaking, if header checks were applied to such
notifications, it would be wrong too - because these checks need to be
separate from those that are applied to normal mail arriving via smtpd
(e.g. to be able to distinguish a spoofed postmaster notification).
In the end, I believe this should be fixed on the Postfix side the
following way:
1. Do not use obsolete From and To header formats in bounce messages and
postmaster notifications.
2. Add a configuration option that would allow users to change
MAILER-DAEMON to something else. Optional, but still suggested.
OR
3. Add postmaster notifications to bounce_template_file OR add a
configuration option that would allow using a template file for
postmaster notifications.
I hope I've explained everything as clearly as possible. English is not
my native language, so I apologize if there are any mistakes.
Thank you very much.
--
Kind regards,
Vladimir