Skip to content

Mail: customize Postfix services (master.cf) #8304

Description

@DavidePrincipi

The Mail application lets administrators add custom Postfix settings with files in the postfix-custom volume, but only for the general settings file, main.cf. The settings of each Postfix service (for example the SMTP listeners on ports 25, 465 and 587, or the delivery agents) live in a separate file, master.cf, which is generated by the application and cannot be customized: any manual change is lost at the next restart or configuration change.

Some setups need to change a single service, for example to limit the number of concurrent connections on port 587, or to add a new listener or delivery method for an external filter or archiving tool.

Proposed solution

Append the contents of a new file, master.append, to the generated master.cf. The file is in the existing postfix-custom volume (the same directory used for main.cf customizations, so it is already included in the backup):

  • a new entry adds a service;
  • an entry with the same service name and type (the first two fields) as a generated one replaces it, because Postfix uses the last entry and logs a "duplicate master.cf entry" warning;
  • the file is not checked: an invalid entry stops Postfix until the file is fixed or removed, and the README explains how to recover;
  • a new fact counts the entries of the file.

Alternative solutions

  • Merge the custom entries into master.cf and check them before starting Postfix, renaming an invalid file and logging a warning: much more code, and the check cannot catch every error (for example an address that cannot be bound), so it would need another safety net when Postfix starts.
  • Replace the whole master.cf with a custom copy: the copy no longer follows the module settings (debug options, restricted senders) or the services added by later updates.
  • A separate volume and directory for master.cf customizations: more files and backup paths to handle for the same result.
  • To disable a service, Postfix already provides the master_service_disable setting, which can be set in a main.cf customization file.

Additional context

Planned for Mail 2.0, together with the Dovecot 2.4 upgrade (#8267).

See also

Activity

  1. moved this from ToDo to In Progress in NethServeron Nov 10, 2026
  2. added
    testing
    on Nov 27, 2026
  3. DavidePrincipi commented on Nov 27, 2026

    @DavidePrincipi
    MemberAuthor

    Implemented by NethServer/ns8-mail#340, available since Mail 2.0.0-beta.4. Test it with the latest testing release, Mail 2.0.0-beta.6.

    Test cases

    Cases marked with ✋ are not covered by the automated test suite (tests/40__api/65__postfix.robot), or only in part: they need a manual check.

    Run the commands as the module user, e.g. runagent -m mail1.

    1. Update keeps the old behavior: after updating an existing Mail instance, /etc/postfix/main.cf.d/master.append does not exist in the postfix container, master.cf is the generated one, and api-cli run module/mail1/get-facts reports postfix_master_custom_count = 0.
    2. Change a service: print the entry with podman exec postfix postconf -Mf submission/inet, copy it into master.append and change maxproc (7th field) from - to 20, then systemctl --user reload postfix. postconf -Mf submission/inet shows 20, and the journal shows the "duplicate master.cf entry" warning. ✋ Open more than 20 concurrent connections to port 587: the extra ones wait.
    3. Add a service: add a new entry, e.g. a second smtpd listener on a free port, and reload: postconf -Mf lists it and the port accepts SMTP connections. The fact counts both entries (2).
    4. Remove the file: delete master.append and reload: master.cf is back to the generated one and the fact is 0.
    5. ✋ Invalid entry: write a broken line (or a listener on a port already in use) and restart Postfix: it fails and the journal shows the postfix/master error. Fix the file with the dedicated container from the README (podman run --rm -ti -v postfix-custom:/srv:z alpine vi /srv/master.append) and restart: Postfix is running again.
    6. ✋ Static replaced entry: with the submission entry replaced, change the restricted sender setting from the UI: the replaced entry does not follow it, as documented in the README.
    7. ✋ Backup and restore: back up the instance with a master.append file, restore it: the file is restored and its entries apply.
    8. ✋ Not appended to main.cf: postconf -n does not contain the master.append lines.
  4. moved this from In Progress to Testing in NethServeron Nov 27, 2026
  5. added
    verified
    on Nov 27, 2026
  6. DavidePrincipi commented on Nov 27, 2026

    @DavidePrincipi
    MemberAuthor

    VERIFIED

  7. removed
    testing
    on Nov 27, 2026
  8. moved this from Testing to Verified in NethServeron Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

verified

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions