Skip to content

Commit 3ce6ede

Browse files
authored
Merge pull request #354 from AndrewPaglusch/fix-ses-sender-header
Add POSTFIX_STRIP_SENDER_HEADER Environment Variable
2 parents d5210af + cbe414d commit 3ce6ede

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ linux/arm64
158158

159159
* `POSTFIX_DEBUG`: Enable debug (default `false`)
160160
* `POSTFIX_MESSAGE_SIZE_LIMIT`: The maximal size in bytes of a message, including envelope information (default `26214400`)
161+
* `POSTFIX_STRIP_SENDER_HEADER`: Strip the Sender header from incoming emails to prevent SES rejection issues (default `false`)
161162
* `POSTFIX_SMTPD_TLS`: Enabling TLS in the Postfix SMTP server (default `false`, possible values: `true`|`may`|`encrypt`|`ask`|`require`, see [Postfix TLS README](https://www.postfix.org/TLS_README.html#client_tls_levels))
162163
* `POSTFIX_SMTPD_TLS_CERT_FILE`: File with the Postfix SMTP server RSA certificate in PEM format
163164
* `POSTFIX_SMTPD_TLS_ECCERT_FILE`: File with the Postfix SMTP server RSA private key in PEM format

rootfs/etc/cont-init.d/00-env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ MAIL_ENCRYPTION=${MAIL_ENCRYPTION:-null}
8383

8484
POSTFIX_DEBUG=${POSTFIX_DEBUG:-false}
8585
POSTFIX_MESSAGE_SIZE_LIMIT=${POSTFIX_MESSAGE_SIZE_LIMIT:-26214400}
86+
POSTFIX_STRIP_SENDER_HEADER=${POSTFIX_STRIP_SENDER_HEADER:-false}
8687
POSTFIX_SMTPD_TLS=${POSTFIX_SMTPD_TLS:-false}
8788
POSTFIX_SMTP_TLS=${POSTFIX_SMTP_TLS:-false}
8889
POSTFIX_RELAYHOST_AUTH_ENABLE=${POSTFIX_RELAYHOST_AUTH_ENABLE:-false}

rootfs/etc/cont-init.d/15-config-postfix.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,20 @@ EOL
257257
chmod o= /etc/postfix/mysql-virtual-alias-domains-and-subdomains.cf
258258
chgrp postfix /etc/postfix/mysql-virtual-alias-domains-and-subdomains.cf
259259

260+
if [ "$POSTFIX_STRIP_SENDER_HEADER" = "true" ]; then
261+
echo "Setting Postfix header_checks to strip Sender header"
262+
cat >/etc/postfix/header_checks <<EOL
263+
/^Sender:/ IGNORE
264+
EOL
265+
cat >>/etc/postfix/main.cf <<EOL
266+
267+
# Header checks configuration
268+
mime_header_checks = regexp:/etc/postfix/header_checks
269+
header_checks = regexp:/etc/postfix/header_checks
270+
EOL
271+
postmap /etc/postfix/header_checks
272+
fi
273+
260274
if [ -f "/data/postfix-main.alt.cf" ]; then
261275
cat "/data/postfix-main.alt.cf" > /etc/postfix/main.cf
262276
fi

0 commit comments

Comments
 (0)