Skip to content

Commit

Permalink
Merge pull request #1 from cgraf-spiria/feature/add-domain-override
Browse files Browse the repository at this point in the history
feat: Add override for origin domain
  • Loading branch information
cgraf-spiria authored Oct 29, 2024
2 parents 7a958d4 + dd800e5 commit 98ca259
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# Mandatory: Server hostname for the Postfix container. Emails will appear to come from the hostname's domain.
#SERVER_HOSTNAME=

# Optional: Override origin domain. Defaults to base domain of server hostname.
#DOMAIN=

# Optional: This will add a header for tracking messages upstream. Helpful for spam filters. Will appear as "RelayTag: ${SMTP_HEADER_TAG}" in the email headers.
#SMTP_HEADER_TAG=

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ The following env variable(s) are optional.

* `MESSAGE_SIZE_LIMIT` This will change the default limit of 10240000 bytes (10MB).

* `DOMAIN` Override origin domain. If not set, defaults to base domain of server hostname.

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" \
Expand Down
6 changes: 4 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ if [ -n "${SMTP_USERNAME_FILE}" ]; then [ -e "${SMTP_USERNAME_FILE}" ] && SMTP_U

SMTP_PORT="${SMTP_PORT:-587}"

#Get the domain from the server host name
DOMAIN=`echo ${SERVER_HOSTNAME} | awk 'BEGIN{FS=OFS="."}{print $(NF-1),$NF}'`
# If not defined, get the domain from the server host name
if [ -z "$DOMAIN" ]; then
DOMAIN=`echo ${SERVER_HOSTNAME} | awk 'BEGIN{FS=OFS="."}{print $(NF-1),$NF}'`
fi

# Set needed config options
add_config_value "maillog_file" "/dev/stdout"
Expand Down

0 comments on commit 98ca259

Please sign in to comment.