diff --git a/Dockerfile b/Dockerfile index c641b9a..8ea7a82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,7 @@ RUN true && \ COPY supervisord.conf /etc/supervisord.conf COPY rsyslog.conf /etc/rsyslog.conf COPY opendkim.conf /etc/opendkim/opendkim.conf +COPY header_checks /etc/header_checks COPY run.sh /run.sh COPY opendkim.sh /opendkim.sh RUN chmod +x /run.sh /opendkim.sh diff --git a/README.md b/README.md index 789af0a..18bfb18 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,10 @@ Example: docker run --rm --name postfix -e "ALLOWED_SENDER_DOMAINS=example.com example.org" -e "MASQUERADED_DOMAINS=example.com" -p 1587:587 boky/postfix ``` +### `HEADER_CHECKS` + +Each message header line is compared against a pre-configured list of patterns. When a match is found the corresponding action is executed. Set to a non-empty string (usually "1" or "yes") enable. + ## `DKIM` **This image is equiped with support for DKIM.** If you want to use DKIM you will need to generate DKIM keys yourself. diff --git a/header_checks b/header_checks new file mode 100644 index 0000000..25fd313 --- /dev/null +++ b/header_checks @@ -0,0 +1,11 @@ +# Sample For Dropping Headers: +#/^Header: IfContains/ IGNORE +/^Received:.*with ESMTPSA/ IGNORE +/^Received:.*with ESMTPS/ IGNORE +/^Received:.*with SMTP/ IGNORE +/^Received:/ IGNORE +/^X-Originating-IP:/ IGNORE +/^X-Mailer:/ IGNORE +/^X-PHP-Originating-Script:/ IGNORE +/^User-Agent:/ IGNORE +/^Mime-Version:/ REPLACE Mime-Version: 1.0 \ No newline at end of file diff --git a/run.sh b/run.sh index 09d0ac7..88c8009 100644 --- a/run.sh +++ b/run.sh @@ -195,11 +195,17 @@ else fi if [ ! -z "$MASQUERADED_DOMAINS" ]; then - echo -en "‣ $notice Setting up address masquerading: ${emphasis}$MASQUERADED_DOMAINS${reset}" + echo -e "‣ $notice Setting up address masquerading: ${emphasis}$MASQUERADED_DOMAINS${reset}" postconf -e "masquerade_domains = $MASQUERADED_DOMAINS" postconf -e "local_header_rewrite_clients = static:all" fi +if [ ! -z "$HEADER_CHECKS" ]; then + echo -e "‣ $notice Setting header_checks" + postconf -e smtp_header_checks="regexp:/etc/header_checks" + +fi + DKIM_ENABLED= if [ -d /etc/opendkim/keys ] && [ ! -z "$(find /etc/opendkim/keys -type f ! -name .)" ]; then DKIM_ENABLED=", ${emphasis}opendkim${reset}"