Skip to content

Commit 99dab61

Browse files
committed
Add postfix' header_check to remove private ip from mail headers
1 parent bde18b7 commit 99dab61

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

Diff for: tasks/setup-postfix.yml

+8
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,11 @@
9898
mode: "0600"
9999
notify:
100100
- postmap recipient_restrictions
101+
102+
- name: Configure header checks
103+
ansible.builtin.template:
104+
src: etc/postfix/header_checks.j2
105+
dest: /etc/postfix/header_checks
106+
mode: "0600"
107+
notify:
108+
- restart postfix

Diff for: templates/etc/postfix/header_checks.j2

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# {{ ansible_managed }}
2+
3+
/^Received: from .*by ({{ mail_hostname }} \(Postfix\) with ESMTPSA.*)/ REPLACE Received: by $1

Diff for: templates/etc/postfix/main.cf.j2

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ delay_warning_time = 1h
113113
disable_dns_lookups = no
114114
disable_mime_output_conversion = no
115115
disable_vrfy_command = yes
116+
header_checks = regexp:/etc/postfix/header_checks
116117

117118
# Masquerading, currently not needed:
118119
#masquerade_classes = envelope_sender, header_sender, header_recipient

Diff for: tests/tests/outgoing/MailCanBeSentFromClientWithAuthenticationTest.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
Received: from sut.mydomain.test ([192.168.56.10])
2424
$$ \t $$by smtp-sink (smtp-sink) with ESMTP id $$ .* $$;
2525
...
26-
Received: from client.localdomain (ip-192.168.56.201.someisp.test [192.168.56.201])
26+
Received: by sut.mydomain.test (Postfix) with ESMTPSA id $$ .* $$
27+
$$ \t $$for <[email protected]>; $$ .* $$
2728
...
2829
Date: $$ .* $$
2930

0 commit comments

Comments
 (0)