Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for an Alternate Submission Port #203

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .gitignore

This file was deleted.

1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ WORKDIR /tmp

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --start-interval=2s --retries=3 CMD /scripts/healthcheck.sh

EXPOSE 587
CMD [ "/bin/sh", "-c", "/scripts/run.sh" ]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ To change the log format, set the (unsurprisingly named) variable `LOG_FORMAT=js
issue a notice when that happens.
- `MASQUERADED_DOMAINS` = domains where you want to masquerade internal hosts
- `SMTP_HEADER_CHECKS`= Set to `1` to enable header checks of to a location of the file for header checks
- `ALT_SUBMISSION_PORT` = Set to port if you need something different than default 587. Example: `8587`
- `POSTFIX_myhostname` = Set the name of this postfix server
- `POSTFIX_mynetworks` = Allow sending mails only from specific networks ( default `127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16` )
- `POSTFIX_message_size_limit` = The maximum size of the message, in bytes, by default it's unlimited
Expand Down
2 changes: 1 addition & 1 deletion configs/master.cf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (no) (never) (100)
# ==========================================================================
smtp inet n - n - - smtpd
#smtp inet n - n - - smtpd
#smtp inet n - n - 1 postscreen
#smtpd pass - - n - - smtpd
#dnsblog unix - - n - 0 dnsblog
Expand Down
9 changes: 9 additions & 0 deletions scripts/common-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,15 @@ postfix_open_submission_port() {
sed -i -r -e 's/^#submission/submission/' /etc/postfix/master.cf
}

postfix_set_alt_submission_port() {
if [ ! -z "$ALT_SUBMISSION_PORT" ]; then
notice "ALT_SUBMISSION_PORT is ${emphasis}$ALT_SUBMISSION_PORT${reset}"
sed -i -r -e 's/^submission/#submission/' /etc/postfix/master.cf
sed -i '/^#submission.*/a\
8587 inet n y n - - smtpd'$'\n' /etc/postfix/master.cf
fi
}

execute_post_init_scripts() {
if [ -d /docker-init.db/ ]; then
notice "Executing any found custom scripts..."
Expand Down
10 changes: 9 additions & 1 deletion scripts/healthcheck.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ if [ -f /tmp/container_is_terminating ]; then
fi

check_postfix() {
port=$(grep -v '^#' /etc/postfix/master.cf | grep 'submission inet')
if [ -n "$port" ]; then
port=587
echo "Submission port is: $port"
else
port=$(grep -E '^[^#].*smtpd$' /etc/postfix/master.cf | awk '{print $1}')
echo "Submission port is: $port"
fi
printf "EHLO healthcheck\nquit\n" | \
{ while read l ; do sleep 1; echo $l; done } | \
nc -w 2 127.0.0.1 587 | \
nc -w 2 127.0.0.1 $port | \
grep -qE "^220.*ESMTP Postfix"
}

Expand Down
1 change: 1 addition & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ postfix_setup_smtpd_sasl_auth # Enable sender sasl auth, if defined
postfix_custom_commands # Apply custom postfix settings
opendkim_custom_commands # Apply custom OpenDKIM settings
postfix_open_submission_port # Enable the submission port
postfix_set_alt_submission_port # Set the alternative submission port
execute_post_init_scripts # Execute any scripts found in /docker-init.db/
unset_sensitive_variables # Remove environment variables that contains sensitive values (secrets) that are read from conf files

Expand Down