From f280c00f87f95987afa1c68a4292175991ad8f7b Mon Sep 17 00:00:00 2001 From: linucksrox Date: Wed, 27 Oct 2021 11:42:03 -0400 Subject: [PATCH] feat: Add ENV option to enable subject line logging --- .env.example | 3 +++ README.md | 2 ++ run.sh | 11 +++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 4b196a6..8af3c2f 100644 --- a/.env.example +++ b/.env.example @@ -31,3 +31,6 @@ # Optional: This will use allow you to set a custom $mydestination value. Default is localhost. #DESTINATION= + +# Optional: This will output the subject line of messages in the log. +#LOG_SUBJECT=yes diff --git a/README.md b/README.md index c102581..d44a446 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ The following env variable(s) are optional. * `DESTINATION` This will define a list of domains from which incoming messages will be accepted. +* `LOG_SUBJECT` This will output the subject line of messages in the log. + To use this container from anywhere, the 25 port or the one specified by `SMTP_PORT` needs to be exposed to the docker host server: docker run -d --name postfix -p "25:25" \ diff --git a/run.sh b/run.sh index 8027f8f..934c2cd 100644 --- a/run.sh +++ b/run.sh @@ -61,11 +61,18 @@ fi #Set header tag if [ ! -z "${SMTP_HEADER_TAG}" ]; then - postconf -e "header_checks = regexp:/etc/postfix/header_tag" - echo -e "/^MIME-Version:/i PREPEND RelayTag: $SMTP_HEADER_TAG\n/^Content-Transfer-Encoding:/i PREPEND RelayTag: $SMTP_HEADER_TAG" > /etc/postfix/header_tag + postconf -e "header_checks = regexp:/etc/postfix/header_checks" + echo -e "/^MIME-Version:/i PREPEND RelayTag: $SMTP_HEADER_TAG\n/^Content-Transfer-Encoding:/i PREPEND RelayTag: $SMTP_HEADER_TAG" >> /etc/postfix/header_checks echo "Setting configuration option SMTP_HEADER_TAG with value: ${SMTP_HEADER_TAG}" fi +#Enable logging of subject line +if [ "${LOG_SUBJECT}" == "yes" ]; then + postconf -e "header_checks = regexp:/etc/postfix/header_checks" + echo -e "/^Subject:/ WARN" >> /etc/postfix/header_checks + echo "Enabling logging of subject line" +fi + #Check for subnet restrictions nets='10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16' if [ ! -z "${SMTP_NETWORKS}" ]; then