From 6783d68f4255839517d950e65cf81402b6d4bf6e Mon Sep 17 00:00:00 2001 From: lucas_nz Date: Tue, 29 Sep 2020 21:33:52 +1300 Subject: [PATCH] Add option to overwrite the From address --- README.md | 4 ++++ run.sh | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 822dfdc..d05842f 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ The following env variable(s) are optional. -v $(pwd)/secrets/:/secrets/ * `ALWAYS_ADD_MISSING_HEADERS` This is related to the [always\_add\_missing\_headers](http://www.postfix.org/postconf.5.html#always_add_missing_headers) Postfix option (default: `no`). If set to `yes`, Postfix will always add missing headers among `From:`, `To:`, `Date:` or `Message-ID:`. +* `OVERWRITE_FROM` This will rewrite the from address overwriting it with the specified address for all email being relayed. Example settings: + OVERWRITE_FROM=email@company.com + OVERWRITE_FROM="Your Name" + 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 4fd4cc9..420de1c 100644 --- a/run.sh +++ b/run.sh @@ -68,6 +68,13 @@ if [ ! -z "${SMTP_NETWORKS}" ]; then fi add_config_value "mynetworks" "${nets}" +if [ ! -z "${OVERWRITE_FROM}" ]; then + echo -e "/^From:.*$/ REPLACE From: $OVERWRITE_FROM" > /etc/postfix/smtp_header_checks + postmap /etc/postfix/smtp_header_checks + postconf -e 'smtp_header_checks = regexp:/etc/postfix/smtp_header_checks' + echo "Setting configuration option OVERWRITE_FROM with value: ${OVERWRITE_FROM}" +fi + #Start services # If host mounting /var/spool/postfix, we need to delete old pid file before