How to Setup Mail Forwarding in Postfix Linux

Postfix is a commonly used MTA (Mail Transfer Agent) program that can receive, deliver or route emails. Postfix can be configured as mail forwarding domains server using virtual_alias_maps settings. The main purpose is to forward mail elsewhere. So this article shows how to setup mail forwarding on a Linux server using the postfix program.

Mail Forwarding

Install Postfix MTA

We are assuming that you have already postfix installed and configured on your system. Or you can use following commands to install Postfix on Linux.

For CentOS/RHEL Systems

# yum install postfix

For Ubuntu/Debian Systems

$ sudo apt-get update
$ sudo apt-get install postfix

For OpenSUSE Systems

# zypper in postfix

Start Postfix MTA and Verify Installation

Use follwoing command to start the Postfix MTA service.
For CentOS/RHEL and OpenSUSE Systems

# chkconfig postfix on
# service postfix start

For Ubuntu/Debian Systems

$ sudo chkconfig postfix on
$ sudo service postfix start

By default postfix used port 25. Now verify that Postfix service is running on your system or not.

# netstat -tulpn | grep 25
tcp    0   0*         LISTEN      5379/master
tcp6   0   0 :::25         :::*              LISTEN      5379/master

Configure Email Forwarding in Postfix

Now configuring postfix to forward mails. Edit Postfix configuration file add change and domain names with your domain name.

# vim /etc/postfix/

Add the following content:

virtual_alias_domains =
virtual_alias_maps = hash:/etc/postfix/virtual

After making changes in configuration files make sure to restart Postfix service.

Email Forwarding Examples

Now we will add rules to forward emails to other email I’d. Let’s starts begin with the email forwarding rules. We will add rules in “/etc/postfix/virtual” file.

# vim /etc/postfix/virtual

1) Now we will add rule to forward emails to email account.

Above rule will forward all sent emails to & to account.

2) Now we will add rule to forward emails to and

Above rule will forward all sent emails to to and accounts.

3) Now we will add rules to forward all domain email to any other emails.

Above rule will forward any email sent to domain to as well as Also forward any email sent to domain to

Update Postfix Lookup Table

After entering the forwarding rules, run the following commands for the new settings to take effect.
For CentOS/RHEL and OpenSUSE Systems

# postmap /etc/postfix/virtual
# service postfix reload

For Ubuntu/Debian Systems

$ sudo postmap /etc/postfix/virtual
$ sudo service postfix reload

Test it now

Now try sending an email to the address on your domain, and you should see the same mail forwarded to other email account.

Enjoy it!

No Responses

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.