If you’re managing a busy email inbox, you know how overwhelming it can be to keep up with the constant flow of messages. One way to streamline your email management process is to set up a catch-all email account using Postfix.
A catch-all email account is an email address that is set up to receive all emails that are sent to your domain, regardless of the recipient’s specified email address. This can be useful if you have multiple email addresses associated with your domain, but you don’t want to miss any important emails that may be sent to an address you haven’t explicitly set up.
Setting Up a Catch-All Email Account in Postfix
Here is the step by step instruction to create a catch-all email account in Postfix server.
- Open the Postfix configuration file: Open the main Postfix configuration file, usually located at “/etc/postfix/main.cf”, using a text editor such as nano or vi.
sudo nano /etc/postfix/virtual
- Set up the virtual_alias_maps parameter: Locate the “virtual_alias_maps” parameter in the configuration file and add the following line below it:
virtual_alias_maps = hash:/etc/postfix/virtual
This sets up a mapping between email addresses and their corresponding destinations.
- Create the virtual file: Create a new file named “virtual” in the “/etc/postfix/” directory.
sudo nano /etc/postfix/virtual
- Add mapping: Add the catch-all mapping to the virtual file by adding the following entry:
@example.com [email protected]
Replace “example.com” with your actual domain name and “[email protected]” with the email address you want to use as your catch-all. This tells Postfix to deliver any email addressed to your domain that is not addressed to a specific email address to the catch-all email address.
- Update the virtual database: Run the following command to update the Postfix virtual database:
sudo postmap /etc/postfix/virtual
- Restart Postfix: Restart the Postfix service by running the following command:
sudo service postfix restart
Once you’ve completed these steps, any emails sent to your domain that aren’t specifically addressed to one of your configured email addresses will be routed to your catch-all email address.
Conclusion
That’s it! You have successfully created a catch-all email account in Postfix. From now on, any email sent to your domain that is not addressed to a specific email address will be delivered to the catch-all email address you specified. This can help you to better manage your inbox and ensure that you don’t miss any important messages.
To know more about catch-all account visit here.
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!