Is it possible to create a catch-all email using postfix which accepts any email address and sends an email to an external address?

Is it possible to create a catch-all email using postfix which accepts any email address and sends an email to an external address?

October 18, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Is it possible to create a catch-all email using postfix which accepts any email address and sends an email to an external address?

Email Forwarding to an External Address using Postfix

The Challenge

You’re facing a unique challenge where you need your system to accept any email address and forward it to a specified external account without relying on third-party services or extensions.

Current Setup

Here’s what you’ve done so far:

  1. Installed Postfix.
  2. Configured Magento with luma.com as the domain.
  3. Created a Linux user account named “contact”.
  4. Set up Postfix to send emails from contact@luma.com.
  5. Configured an aliases file to forward root and contact emails to your Gmail address.

The Problem

You’re trying to achieve a catch-all configuration, meaning any email sent to the server should be forwarded to your external account. You’ve attempted this using virtual alias domains and maps, but you need it to work for any domain, not just luma.com.

What Didn’t Work

  • Setting up virtual_alias_domains and virtual_alias_maps.
  • Using a wildcard or regular expression for the domain.

The Solution

Understanding Catch-All Forwarding

Catch-all forwarding is achieved using the catch_all_address parameter in Postfix. This specifies where to redirect all emails that don’t match any other rules.

Step 1: Create a New User

Create a new Linux user account, for example:

sudo adduser catchall

Step 2: Edit the Main Configuration File

Open /etc/postfix/main.cf and add or modify these lines:

catch_all_address = catchall@luma.com
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-forward.conf

You’re specifying that all unmatched emails should be forwarded to catchall@luma.com.

Step 3: Configure MySQL Database

Create a new MySQL database and table for Postfix virtual forwarding. Here’s an example of what the mysql-virtual-forward.conf file might look like:

user = root
password = your_root_password
dbname = postfix_virtual
table  = forward
hosts  = localhost

Step 4: Update the Aliases File

Update your aliases file (/etc/postfix/aliases) to include this line:

catchall: me@gmail.com

Now, run newaliases to rebuild Postfix’s alias database.

Step 5: Restart Postfix

Finally, restart Postfix for the changes to take effect:

sudo systemctl restart postfix

Conclusion

By following these steps, you should now have a functioning catch-all configuration that forwards all incoming emails to your specified external address. This setup ensures that no matter what email address is used to send an email to your server, it will always be forwarded to me@gmail.com.

Remember, the key was setting up catch_all_address and using MySQL to manage the virtual forwarding rules.

For more detailed information on managing Postfix configurations, check out our guide on LaravelCompany.

Extensions Configuration Email Customers

Our network