Add catch-all address to Mail Server

Add catch-all address to Mail Server

[This modification to Mail Server configuration files must be repeated whenever Mail Server package is upgraded]


When you run a mail server there will doubtless be messages sent to addresses that there is no corresponding inbox. This can happen if addresses are mis-typed or if you want to use random addresses when you do online shopping (good for tracking when a business has been hacked or sold its customer database).

Coming from the Mac OS X Server mail application where a catch-all setting existed, and every hosted domian and email service I've used too, it was a surprise that Mail Server doesn't have this facility in its DSM interface: any mail to addresses without a corresponding DSM account or alias will be bounced back to the sender.

The following steps add a catch-all account by SSH'ing to the DSM command line and editing three Mail Server configuration files within the package itself.


Before starting, within Mail Server's DSM interface you must have created an account that you want to use to receive these mails.

The setup I have uses the DSM LDAP Server to define users, but this also worked when I used DSM local users. The LDAP service uses the same domain as the mail server.


The following actions probably are 'belt and braces' in that DSM packages often regenerate configuration files when the package is stopped/started and the NAS is rebooted, but these changes definitely work and persist until the files are all overwritten during package upgrade. As for the 'vi' text editor: this is my preference but you can use whatever text editor you prefer.

1. The first step is to log on to the NAS using SSH as an admin user.

2. Edit the current configuration file.

sudo vi /var/packages/MailServer/target/etc/

Go to the end of the file and add the following lines, replacing '[email protected]' with either the DSM local username or LDAP username (email address). Save and exit.​
## Catchall email address - start ##
luser_relay = [email protected]
local_recipient_maps =
## Catchall email address - end ##

3. Repeat the edit in the template configuration file.

sudo vi /var/packages/MailServer/target/etc/template/main.template

Insert the same lines as step 2 to the end of the file.​

4. Update the daemon configuration file [I think this keeps the changes after reboot].

sudo vi /var/packages/MailServer/target/scripts/

Search for this line​

    /bin/mv /tmp/tempinfo $PostfixConf

Before the above line insert these lines:​

    echo -e "## Catchall email address ##" >> /tmp/tempinfo
    echo -e "luser_relay = [email protected]" >> /tmp/tempinfo
    echo -e "local_recipient_maps =" >> /tmp/tempinfo
    echo -e "## Catchall email address ##" >> /tmp/tempinfo
    echo -e "" >> /tmp/tempinfo

5. To activate the changes the easiest way is to stop and restart Mail Server using Package Center. If you have MailStation running then you'll have to stop this first.

6. Test the catch-all works by sending emails to account names that you know don't exist.

  • Like
Reactions: SynoMan and Rusty