wagner helps you

Quick way to forward mails via postfix

Thanks to Ben Tasker

Assuming you’re running Postfix, it’s as simple as the steps below

First we make sure the virtual mappings file is enabled

vim /etc/postfix/main.cf

# Scroll down until you find virtual_alias_maps

# Make sure it reads something like
virtual_alias_maps = hash:/etc/postfix/virtual
# We also need to make sure the domain is enabled

Save and exit, next we add the aliases to our mapping file

nano /etc/postfix/virtual
# Forward mail for admin@example.com to jo.bloggs@hotmail.com
admin@example.com  jo.bloggs@hotmail.com

Simple! And if we want to send to two different addresses at once, we just specify them

admin@example.com  jo.bloggs@hotmail.com jos.wife@hotmail.com

Finally, we just need to create a hash (actually later versions of Postfix don’t require this)

postmap /etc/postfix/virtual

It’s exactly the same principle as passing mail into a local user’s mailbox.