DevHeads.net

Prevent addition of (Resent-)From: header

Postfix users,

I think I have an understanding of my problem, but I may be incorrect
and can use some additional expertise. I recently modified an account
on my system to forward all mail for a particular user to some python
code. I modified the /etc/alias file and then ran newaliases.

Postfix is doing exactly what it should as is the python code. What I
noticed though is that a header is being prepended onto the original
email. From what I can tell this is done via the cleanup daemon, with
the code being found within cleanup_message.c.

The newly added header contains the From and Date fields. Is it
possible to prevent this from happening outside of removing the
corresponding C code and compiling a custom postfix version?

I've reviewed the man pages for cleanup(8), from what I can tell, the
only relevant control is "always_add_missing_headers" which defaults
to "no" (although I manually set this to "no").

Within the C code there are additional references for other checks:

if ((state->hdr_rewrite_context || var_always_add_hdrs)
&& (state->headers_seen & (1 << (state->resent[0] ?
HDR_RESENT_FROM : HDR_FROM))) == 0)

Wasn't sure if there was something I can do with the header checks or
if there was something else I could configure to prevent this
occurring. I didn't find anything with the man pages for
header_checks(5) that stood out as a possible configuration option.

Thanks!
Rick

Comments

Re: Prevent addition of (Resent-)From: header

By Wietse Venema at 10/10/2017 - 18:15

When Postfix receives a malformed message that begins with non-header
text, Postfix will prepend From: etc. just like it does with any
local message submission.

The Postfix-generated header is followed by a blank line and the
content of the malformed message.

Is the message injected through the Postfix sendmail command, is
it injected through the SMTP server port, or via some other mechanism?

What is the message content immediately after the Postfix-generated
header?

Wietse