forward emails to non existing accounts to one central one in Postfix

August 6, 2019 445 views
Initial Server Setup Messaging Email Security Solutions

Hey guys,

I have a (Linux) server running with Postfix as an email server. When registering to a new site I do not want to use a single mail twice so when my email gets leaked by a security breach at any site only this one mail get published in lists to the internet, but because I only used it on that site it would be useless. By this meaning, I would always have to create a new email user whenever I sign up to a site and I would also have to enable email forwarding to the “main” email (having a ton of addresses is not an option). As I am lazy I do not want to do this so I am looking for a way to automatic forward emails to a specified account when the recipient’s email would be on my server but does not exist.

best regards Thore

1 Answer

Hi ThoreTheWookie,

What you are looking for is setting up a catchall mailbox.

With a catchall mailbox, all your e-mails will be redirected to one account. Some websites send confirmation e-mail messages to the e-mail account you use to register. In this case, using a catchall would be the best option.

Let’s set a catchall Postfix mailbox then

  • Edit /etc/postfix/virtual and configure your catch-all address like below.
@example.com myuser
  • Let’s say you don’t want all mails to be forwarded to this catchall mailbox. You can add exceptions so that you can use the accounts normally.Add them also in /etc/postfix/virtual file. The below configuration will send all emails to user “myuser” except emails of DO@example.com and test@example.com.
@example.com myuser
DO@example.com  info
test@example.com support
  • Save /etc/postfix/virtual file and execute the following command.
postmap /etc/postfix/virtual
  • Now to update the Postfix’s configuration file - /etc/postfix/main.cf
virtual_alias_maps = hash:/etc/postfix/virtual
  • After the change has been saved, you’ll need to reload the Postfix configuration. To do so, execute:
service postfix reload

Now you have a catchall mailbox configured.

Kind regards,
Kalin D.

Have another answer? Share your knowledge.