NS8 Postfix remove/hide client sender ip?

NethServer Version: NS8
Module: Postfix/ mail

Hello,

Is it possible to hide/ remove my sender name and IP address when I send an email?
The last “Received:..” line should not be there:

Received: from ns8.ifam-erfurt.de (…)
by xxx.kasserver.com (Postfix) with ESMTPSA id 3A80870D044B;
Wed, 25 Mar 2026 13:41:48 +0100 (CET)

Received: from [192.168.xx.yy] (pcname.ifam-erfurt.de [192.168.xx.yy])

by ns8.ifam-erfurt.de (Postfix) with ESMTPSA id 25D5D181B4C2B;
Wed, 25 Mar 2026 12:41:47 +0000 (UTC)

Postfix provides header_checks to remove headers.

Enter mail app environment:

runagent -m mail1

Add a custom myoverride.cf file…

podman exec -ti postfix vi /etc/postfix/main.cf.d/myoverride.cf

with following content:

header_checks = regexp:/etc/postfix/main.cf.d/header_checks

Add a header_checks file containing the headers regexp to remove…

podman exec -ti postfix vi /etc/postfix/main.cf.d/header_checks

for example with following content:

/^Received:.*with ESMTPSA/    IGNORE

Restart postfix to apply the config:

systemctl --user restart postfix

See also:

Good morning mrmarkuz,

Thank you so much for the instructions! It works—the last row is gone. I had already read about the basic approach in forums and blogs, but I lack the knowledge when it comes to working with containers.

One more question: the second-to-last line (with “Received: from ns8.ifam-erfurt.de“) isn’t filtered, even though it also contains the string “ESMTPSA.” Why is that? Is there a way to filter that one too?

Thank you very much!

Mario

1 Like

Here’s a howto about working with containers.

Strange, it should be filtered. Did you check the headers in the sent mails?

Maybe it helps to simplify the regexp as explained here?

/^Received:/    IGNORE

No, I send emails to my external email provider using the “Mail Relay” feature in NS8. To test the sent header lines, I use a public echo mailer such as “echo@univie.ac.at”. This allows me to verify that sending and receiving are working correctly and see my exact mail header (which is sent back to me).

I will test this… :slightly_smiling_face: :+1:

1 Like

Maybe that smarthost adds the headers?

I tested using direct sending of a testmail to echo@univie.ac.at and the answer just had 3 received headers:

Received: from mail.domain.tld
    by node1.domain.tld with LMTP
    id sfN9ED8HxkpBwAAaGOrxQ
    (envelope-from <>)
    for <markus@mail.domain.tld.localhost>; Thu, 26 Mar 2026 10:15:27 +0000
Received: from grace.univie.ac.at (grace.univie.ac.at [131.130.3.115])
    (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
    key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
    (No client certificate requested)
    by mail.domain.tld (Postfix) with ESMTPS id 9B86F120337DC
    for <markus@domain.tld>; Thu, 26 Mar 2026 10:15:21 +0000 (UTC)
Received: from mail by grace.univie.ac.at with local (Exim 4.99.1)
    id 1w5hkH-0000007KW-1gJh
    for markus@domain.tld;
    Thu, 26 Mar 2026 11:15:21 +0100

EDIT:

When using the simplified regex there’s just 1 received header in the answer mail:

Received: from mail.domain.tld
    by ctb1.domain.tld with LMTP
    id TsKcBmMWkCGgAAu9VA
    (envelope-from <>)
    for <markus@mail.domain.tld.localhost>; Thu, 26 Mar 2026 10:20:19 +0000

I’ve now done various tests. Here are the results:

You’re right, the mail relay/ smart host is causing the “Received: from ns8.ifam-erfurt.de” entry. If I send the email directly via the ALL-INKL webmail interface, this entry doesn’t appear. It doesn’t matter what the filter settings are.

So I will leave the settings as follows:

  • Send via mail relay/ smarthost
  • Filter setting: /^Received:/ IGNORE

It is important that local IPs and names do not appear.

When I compare this behaviour with my previous NS7 installation, it behaves exactly the same way.

I’ll also add:

- Filter setting: /^User-Agent:/ IGNORE

I think that’s ideal!

Many thanks and have a lovely day! :wink:

1 Like