Skip to content

Commit

Permalink
Strips sender details (IP, client, user agent) when sending (huan#91)
Browse files Browse the repository at this point in the history
* Strips sender's IP, client, and user agent headers

* Bumping patch verison number
  • Loading branch information
dgraziotin authored Feb 17, 2021
1 parent 6f1cad7 commit aea2357
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RUN apk add --update --no-cache \
openssl \
postsrsd \
postfix \
postfix-pcre \
syslog-ng \
tzdata \
\
Expand All @@ -41,7 +42,7 @@ COPY install/main.dist.cf /etc/postfix/main.cf
COPY install/master.dist.cf /etc/postfix/master.cf
COPY install/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
COPY install/opendkim.conf /etc/opendkim/opendkim.conf

COPY install/sender_header_filter.pcre /etc/postfix/sender_header_filter.pcre
RUN cat /dev/null > /etc/postfix/aliases && newaliases \
&& echo simple-mail-forwarder.com > /etc/hostname \
&& mkdir -p /run/opendkim && chown opendkim:opendkim /run/opendkim \
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ It is highly advised to mount `/var/db/dkim/` folder to host, so generated keypa
docker run -e SMF_CONFIG="$SMF_CONFIG" -p 25:25 -v $(pwd)/dkim:/var/db/dkim/ zixia/simple-mail-forwarder
```
Stripping sender details
------------------------
SMF will strip the sender's IP, client, and user agent headers when the `SMF_SENDERPRIVACY` environment variable is defined.

Helper Scripts
--------------------

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0
1.4.1
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Environment Variables:
SMF_CONFIG - mail forward addresses mapping list.
SMF_MYNETWORKS - configure relaying from trusted IPs, see http://www.postfix.org/postconf.5.html#mynetworks
SMF_RELAYHOST - configure a relayhost
SMF_SENDERPRIVACY - strips sender's IP, client, and user agent.
this creates a new smtp server which listens on port 25,
forward all email from
Expand Down Expand Up @@ -188,6 +189,12 @@ function start_postfix {
postconf -e smtp_tls_CAfile=/etc/ssl/certs/ca-certificates.crt
fi

if [ "$SMF_SENDERPRIVACY" != "" ]
then
echo "Stripping sender's IP, client, and user agent."
postconf -e smtp_header_checks=pcre:/etc/postfix/sender_header_filter.pcre
fi

postfix start

# migrating older single-domain DKIM (/var/db/dkim/default.*) to /var/db/dkim/$HOSTNAME/default.*
Expand Down
5 changes: 5 additions & 0 deletions install/sender_header_filter.pcre
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/^(Received: from)[^\n]*(.*)/ REPLACE $1 127.0.0.1 (localhost [127.0.0.1])$2
/^User-Agent/ IGNORE
/^X-Originating-IP/ IGNORE
/^X-Mailer:/ IGNORE
/^Mime-Version:/ IGNORE

0 comments on commit aea2357

Please sign in to comment.