Setting up Mail Forwarding in Postfix
To setup mail forward in postfix,
Edit postfix config file
1 |
vi /etc/postfix/main.cf |
Add
1 2 |
virtual_alias_domains = /etc/postfix/virtual_alias_domains virtual_alias_maps = hash:/etc/postfix/virtual_alias_maps |
Create file /etc/postfix/virtual_alias_domains
1 |
vi /etc/postfix/virtual_alias_domains |
Add your domains on this file. 1 Per line.
Example
1 2 3 4 |
[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.
1 |
vi /etc/postfix/virtual_alias_maps |
Add
1 2 |
info@webhostingneeds.com info@serverok.in info@netfreehost.com info@serverok.in |
here email coming to [email protected] and [email protected] get forwarded to [email protected]
If you need catch all email account, just use
1 |
@yourdomain.com you@your-email-provider.com |
If you want email forwarded to more than one recipient, add them one after other like
1 |
you@yourdomain.com you@your-email-provider-1.com you@your-email-provider-2.com |
Now run
1 |
postmap /etc/postfix/virtual_alias_maps |
Restart postfix
1 |
systemctl restart postfix |
You need to set MX record of your domain to point to server running the postfix mail server to receive mails.