Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strips sender details (IP, client, user agent) when sending #91

Merged
merged 4 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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