Postfix email forward

On an Ubuntu Server, i done following to setup email forwarding.

Install postfix

apt -y install postfix

Edit /etc/postfix/main.cf, add following

Advertisement

vi /etc/postfix/main.cf

Add

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

vi /etc/postfix/vmailbox

Add

user1@YOUR-DOMAIN_HERE.com    YOUR-DOMAIN_HERE.com/user1

Create alias file, used for mail forwarding

vi /etc/postfix/virtual

Add

admin@YOUR-DOMAIN_HERE.com YOU@gmail.com

Wth above configuration, mail coming to admin@YOUR-DOMAIN_HERE.com will get forwarded to YOU@gmail.com. Email coming to user1@YOUR-DOMAIN_HERE.com get delivered to local mailbox folder.

Now run following commands to make hashmap

postmap /etc/postfix/vmailbox
postmap /etc/postfix/virtual

Restart postfix

systemctl restart postfix
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