Setting up Mail Forwarding in Postfix

To setup mail forward in postfix,

Edit postfix config file

vi /etc/postfix/main.cf

Add

Advertisement

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

info@webhostingneeds.com info@serverok.in
info@netfreehost.com info@serverok.in

here email coming to info@webhostingneeds.com and info@netfreehost.com get forwarded to info@serverok.in

If you need catch all email account, just use

@yourdomain.com you@your-email-provider.com

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

you@yourdomain.com you@your-email-provider-1.com you@your-email-provider-2.com

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.

Add a comment

Leave a Reply

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

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement