Postfix email forward
On an Ubuntu Server, i done following to setup email forwarding.
Install postfix
1 |
apt -y install postfix |
Edit /etc/postfix/main.cf, add following
1 |
vi /etc/postfix/main.cf |
Add
1 2 3 4 5 6 7 |
virtual_mailbox_domains = YOUR-DOMAIN_HERE.com virtual_mailbox_base = /var/mail/vhosts virtual_mailbox_maps = hash:/etc/postfix/vmailbox virtual_minimum_uid = 100 virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 virtual_alias_maps = hash:/etc/postfix/virtual |
Create Virtual mailbox
1 |
vi /etc/postfix/vmailbox |
Add
1 |
user1@YOUR-DOMAIN_HERE.com YOUR-DOMAIN_HERE.com/user1 |
Create alias file, used for mail forwarding
1 |
vi /etc/postfix/virtual |
Add
1 |
admin@YOUR-DOMAIN_HERE.com YOU@gmail.com |
Wth above configuration, mail coming to admin@YOUR-DOMAIN_HERE.com will get forwarded to [email protected]. Email coming to user1@YOUR-DOMAIN_HERE.com get delivered to local mailbox folder.
Now run following commands to make hashmap
1 2 |
postmap /etc/postfix/vmailbox postmap /etc/postfix/virtual |
Restart postfix
1 |
systemctl restart postfix |