feat: Add ENV option to enable subject line logging

This commit is contained in:
linucksrox 2021-10-27 11:42:03 -04:00 committed by Juan Luis Baptiste
parent f831f935b9
commit f280c00f87
3 changed files with 14 additions and 2 deletions

View File

@ -31,3 +31,6 @@
# Optional: This will use allow you to set a custom $mydestination value. Default is localhost. # Optional: This will use allow you to set a custom $mydestination value. Default is localhost.
#DESTINATION= #DESTINATION=
# Optional: This will output the subject line of messages in the log.
#LOG_SUBJECT=yes

View File

@ -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. * `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: 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" \ docker run -d --name postfix -p "25:25" \

11
run.sh
View File

@ -61,11 +61,18 @@ fi
#Set header tag #Set header tag
if [ ! -z "${SMTP_HEADER_TAG}" ]; then if [ ! -z "${SMTP_HEADER_TAG}" ]; then
postconf -e "header_checks = regexp:/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_tag 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}" echo "Setting configuration option SMTP_HEADER_TAG with value: ${SMTP_HEADER_TAG}"
fi 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 #Check for subnet restrictions
nets='10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16' nets='10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16'
if [ ! -z "${SMTP_NETWORKS}" ]; then if [ ! -z "${SMTP_NETWORKS}" ]; then