Skip to content
Merged
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
33 changes: 17 additions & 16 deletions docs/content/config/advanced/override-defaults/postfix.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@
title: 'Override the Default Configs | Postfix'
---

The Postfix default configuration can easily be extended by providing a `docker-data/dms/config/postfix-main.cf` in postfix format.
This can also be used to add configuration that is not in our default configuration.
[Our default Postfix configuration](https://github.com/docker-mailserver/docker-mailserver/blob/master/target/postfix/main.cf) can easily be extended to add parameters or modify existing ones by providing a `docker-data/dms/config/postfix-main.cf`. This file uses the same format as Postfix `main.cf` does ([See official docs](http://www.postfix.org/postconf.5.html) for all parameters and syntax rules).

For example, one common use of this file is for increasing the default maximum message size:
!!! example "Example"

```cf
# increase maximum message size
message_size_limit = 52428800
```
One can easily increase the [backwards-compatibility level](http://www.postfix.org/postconf.5.html#compatibility_level) and set new Postscreen options:

That specific example is now supported and can be handled by setting `POSTFIX_MESSAGE_SIZE_LIMIT`.
```cf
# increase the compatibility level from 2 (default) to 3
compatibility_level = 3
# set a threshold value for Spam detection
postscreen_dnsbl_threshold = 4
```

!!! note

[Postfix documentation](http://www.postfix.org/documentation.html) remains the best place to find configuration options.
!!! help "How are your changes applied?"

Each line in the provided file will be loaded into postfix.
The custom configuration you supply is appended to the default configuration located at `/etc/postfix/main.cf`, and then `postconf -nf` is run to remove earlier duplicate entries that have since been replaced. This happens early during container startup before Postfix is started.

In the same way it is possible to add a custom `docker-data/dms/config/postfix-master.cf` file that will override the standard `master.cf`. Each line in the file will be passed to `postconf -P`. The expected format is `<service_name>/<type>/<parameter>`, for example:
---

Similarly, it is possible to add a custom `docker-data/dms/config/postfix-master.cf` file that will override the standard `master.cf`. **Note**: Each line in this file will be passed to `postconf -P`, i.e. **the file is not appended as a whole** to `/etc/postfix/master.cf` like `docker-data/dms/config/postfix-main.cf`! The expected format is `<service_name>/<type>/<parameter>`, for example:

```cf
# adjust the submission "reject_unlisted_recipient" option
submission/inet/smtpd_reject_unlisted_recipient=no
```

Run `postconf -P` in the container without arguments to see the active master options.

!!! note
!!! attention
There should be no space between the parameter and the value.

Have a look at the code for more information.
Run `postconf -Mf` in the container without arguments to see the active master options.
19 changes: 7 additions & 12 deletions target/scripts/startup/setup-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -731,20 +731,15 @@ function _setup_postfix_virtual_transport

function _setup_postfix_override_configuration
{
_log 'trace' 'Setting up Postfix Override configuration'
_log 'debug' 'Overriding / adjusting Postfix configuration with user-supplied values'

if [[ -f /tmp/docker-mailserver/postfix-main.cf ]]
then
while read -r LINE
do
# all valid postfix options start with a lower case letter
# http://www.postfix.org/postconf.5.html
if [[ ${LINE} =~ ^[a-z] ]]
then
postconf -e "${LINE}"
fi
done < /tmp/docker-mailserver/postfix-main.cf
_log 'trace' "Loaded '/tmp/docker-mailserver/postfix-main.cf'"
cat /tmp/docker-mailserver/postfix-main.cf >>/etc/postfix/main.cf
# do not directly output to 'main.cf' as this causes a read-write-conflict
postconf -n >/tmp/postfix-main-new.cf 2>/dev/null
mv /tmp/postfix-main-new.cf /etc/postfix/main.cf
_log 'trace' "Adjusted '/etc/postfix/main.cf' according to '/tmp/docker-mailserver/postfix-main.cf'"
else
_log 'trace' "No extra Postfix settings loaded because optional '/tmp/docker-mailserver/postfix-main.cf' was not provided"
fi
Expand All @@ -758,7 +753,7 @@ function _setup_postfix_override_configuration
postconf -P "${LINE}"
fi
done < /tmp/docker-mailserver/postfix-master.cf
_log 'trace' "Loaded '/tmp/docker-mailserver/postfix-master.cf'"
_log 'trace' "Adjusted '/etc/postfix/master.cf' according to '/tmp/docker-mailserver/postfix-master.cf'"
else
_log 'trace' "No extra Postfix settings loaded because optional '/tmp/docker-mailserver/postfix-master.cf' was not provided"
fi
Expand Down