I am configuring my Linux system to accept incoming emails and forward them to needed email accounts. For this setup, the Ubuntu operating system is used with the postfix mail server. We can configure Postfix as mail forwarding server using the virtual_alias_maps settings.

Advertisement

This tutorial will help you to set up a postfix server to forward the email to other email accounts.

Setup Mail Forwarding in Postfix

Forwarding emails to remote mailboxes via Postfix does not require local mailboxes. Any email received by the Postfix will be routed to remote mailboxes based on configuration.

Below example configuration will help you to configure example.com as mail forwarding domain on Postfix.

Edit Postfix main.cf in editor:

sudo vi /etc/postfix/main.cf 

Add your mail forwarding domain to virtual_alias_domains and a configuration file with routing rules with virtual_alias_maps. You can add multiple virtual_alias_domains with space-separated.

virtual_alias_domains = example.com tecadmin.net
virtual_alias_maps = hash:/etc/postfix/virtual

Next create and edit /etc/postfix/virtual file in editor:

sudo vi /etc/postfix/virtual 

Now add the Postfix email forwarding rules as per your requirements. Below is some example:

  1. Forward rahul@example.com emails to rahul@remote.example.com
    rahul@example.com       rahul@remote.example.com 
    
  2. Forwarding all the emails sent to any email id for domain example.com to catch-all@remote.example.com
    @example.com       catch-all@remote.example.com 
    
  3. Forward incoming emails to support@example.com to the local Unix root account.
    support@example.com       root
    

Save and close the file. Next, create a hash file of the virtual and start postfix service.

postmap /etc/postfix/virtual 
service postfix restart 

Conclusion

In this tutorial, you have learned to configured Postfix to forward emails to other email accounts.

Share.
Leave A Reply


Exit mobile version