You may want to install a catch-all e-mail account on a Linux server for catching the bounced mails from a mailing for instance. Each unique return-path can then be used to map it to a bounced e-mail and unsubscribe that user from your mailing. Using Postfix, that’s a simple thing.
Check if no other MTA is running
You probably don’t want any other mailserver running besides postfix. So for safety, only continue if the command below does nothing.
# telnet localhost 25 Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refused
Please note, Linux systems by default will run a sendmail or Exim on localhost to send e-mails. If you’re sure you can stop that mailservice, use the init.d scripts to stop it.
Install postfix
Use your trusty package manager.
# yum install postfix # chkconfig postfix on
Configure your catch-all
Create a /etc/postfix/virtual file with the following content.
# grep -vP "^#" /etc/postfix/virtual @my.server.tld catchall
You can replace the @my.server.tld with the actual domain you want to have the catch-all for. You can simply add more lines in that file with additional domains if you need them.
Then, run the postmap command to conver the text file to a hashmap that Postfix understands.
# postmap /etc/postfix/virtual
Edit your Postfix’s main.cf file and make sure the following line is present.
# grep -P 'virtual_alias_maps' /etc/postfix/main.cf virtual_alias_maps = hash:/etc/postfix/virtual
And restart your Postfix to make the changes active.
# service postfix restart
Testing it
You should be able to telnet to your server and send a test mail to a dummy account.
# telnet my.server.tld 25 Trying 127.0.0.1... Connected to servername (1.2.3.4). Escape character is '^]'. 220 servername ESMTP Postfix HELO server.tld 250 servername mail from: <test@test.be> 250 2.1.0 Ok rcpt to: <randomdata1234@my.server.tld> <u>250 2.1.5 Ok</u> ^] telnet> quit Connection closed.
The line shown in underline is the answer you would look for, where the server accepts the random user you’ve just sent an e-mail to. And there, you’ve just set up a catchall e-mail address in Postfix. Seeing as you’ll receive loads of spam as well, you want to make sure you clean that mailbox regularly. ;-)