Setting up Mail Forwarding in Postfix

To setup mail forward in postfix,

Edit postfix config file

vi /etc/postfix/main.cf

Add

virtual_alias_domains = /etc/postfix/virtual_alias_domains
virtual_alias_maps = hash:/etc/postfix/virtual_alias_maps

Create file /etc/postfix/virtual_alias_domains

vi /etc/postfix/virtual_alias_domains

Add your domains on this file. 1 Per line.

Example

[root@s125359 ~]# cat /etc/postfix/virtual_alias_domains
webhostingneeds.com
netfreehost.com
[root@s125359 ~]# 

Here i have 2 domains added, postfix will service as incoming email server for these 2 domains.

Now create /etc/postfix/virtual_alias_maps, this file will list all email accounts you need and where the email needed to be forwarded to.

vi /etc/postfix/virtual_alias_maps

Add

[email protected] [email protected] 
[email protected] [email protected]  

here email coming to [email protected] and [email protected] get forwarded to [email protected]

If you need catch all email account, just use

@yourdomain.com [email protected]

If you want email forwarded to more than one recipient, add them one after other like

[email protected] [email protected] [email protected]

Now run

postmap /etc/postfix/virtual_alias_maps

Restart postfix

systemctl restart postfix

You need to set MX record of your domain to point to server running the postfix mail server to receive mails.

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *