Catch-All email account is used to collect all emails sent to any email of a domain. It helps us to avoid losing emails due to misspelled addresses. While using the catch-all address you may receive spam messages and many other bounce messages that sent to any-email (at) your-domain.com
.
This tutorial will help you to set up a catch-all email address with a postfix server.
Step 1 – Setup Catch-All Account
A catch-all account can be created by adding a virtual aliases to the postfix server. To add an alias edit /etc/postfix/virtual configuration file:
nano /etc/postfix/virtual
Then add a catch-all address like below:
@example.com myuser
You may also have some actual email accounts on your domain and you need to forward emails of that accounts to the correct mailbox. Then you can also create virtual alias for that email address and forward it to specific user’s mailboxes. Use the below configuration, which will send all emails to user “myuser” except emails of [email protected] and [email protected]
@example.commyuser [email protected]info [email protected]support
Save and close configuration file, then execute the following command to create or update hash file.
postmap /etc/postfix/virtual
The above command will create /etc/postfix/virtual.db
file in your system. Which will be used by the Postfix server.
Step 2 – Update Postfix Configuration File
Now, you need to add virtual_alias_maps to the Postfix main configuration file. Just edit Postfix configuration file /etc/postfix/main.cf in your favorite text editor:
nano /etc/postfix/main.cf
Add the following entry to the end of the file
virtual_alias_maps = hash:/etc/postfix/virtual
Save the file and close it.
Step 3 – Reload Postfix Server
After making all the changes, reload the postfix service to apply all settings. Use the following command to reload the postfix configuration.
systemctl reload postfix
You have completed postfix catch-all email setting configuration. Click here to read more about catch all account.
11 Comments
On newer versions of postfix (like mail_version = 3.4.14) you should not forget the postmap command.
Just writing into file “virtual” will not solve the issue.
You’ll have to create “virtual.db” with postmap command.
sudo postmap virtual
sudo systemctl restart postfix
2021 and it help me
thank you
Greetings! Very useful advice within this post!
It’s the little changes that produce the biggest changes.
Thanks a lot for sharing!
Hey, it’s been four years and this is still helping people, thanks so much, just right to the point.
Mateo/Miky.
I have multiple virtual domains in Mail Server/Postfix on my Synology and what I found was if you added multiple catch-alls in Virtual then all the caught mail would just go to one domain. How I got around this was within the Synology interface, where you enter your list of domains, the first/primary domain needs to be anything other than your actual domains, so for instance mylocalmail.com. You then add all your other domains after this one. (Sorry I can’t remember what file this is actually editing within Linux). You can then add as many @domain.com entries to virtual as you like. They don’t even need to be the first line in Virtual.
Thanks, It works like a charm. However, I am have multiple virtual domains on my server. The above instructions work for the main domain (example.com) hosted on the server. How can I set up catch-all for all of the hosted domains and users?
So the catchall needs to be in the first line, but what if I have several virtual domains? one file per domain? help plz 🙁
It worked for me.
Hi,
Thanks for this article. But you know, I didn’t find a place where I could find caught emails. Could you write where is it?
Thank you!!! Couldn’t get this to work until I saw you needed “postmap /etc/postfix/virtual”
Thanks again!
Thank you for this guide. It’s the only one I’ve found which says that the catch-all line needs to be the first line in virtual. Even Postfix’s documentation has it at the end of the list. I’ve already wasted several hours on trying to get the catch-all to work properly, so thank-you for stopping from wasting even more!