Postfix catch all outgoing emails

How to setup postfix server for catching all outgoing email for a local development server

Here is how to catch all outgoing emails from a server. It is helpful for development environment.

1. Install postfix and postfix-pcre

sudo apt install postfix postfix-pcre

2. In /etc/postfix/mail.cf file, add the following at the bottom

virtual_alias_maps = pcre:/etc/postfix/virtual

3. In /etc/postfix/virtual file add the following:

/.*@.*/  $user

Replace $user with the user account. Example www-data if you want the user www-data to catch all the emails.

Source:

  1. https://serverfault.com/questions/320320/postfix-development-server-intercept-all-outgoing-mail