Postfix Forward Email To Another Email Account

I‘ve multiple virtual domain hosted on CentOS Postfix server. How do I forward selected virtual domain email to yahoo / gmail or other email account using Postfix email server?

Postfix can be configured as mail forwarding domains server using virtual_alias_maps settings. There are two type of configurations here.

Postfix Mail Forwarding Domains

This is useful if you do not have local mailboxes and server is not acting as MX backup (do not use the following if relay_domains sql map or virtual map is configured). The main purpose of these domains is to forward mail elsewhere. The following example shows how to set up as a mail forwarding domain. Open file, enter:
# vi /etc/postfix/
Make sure following two line exists:

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

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

Open /etc/postfix/virtual file, enter:
# vi /etc/postfix/virtual
Forward email sent to to

You can also implement a catch-all address i.e. email sent to and should be forwarded to

Save and close the file. Type the following command to restart postfix:
# postmap /etc/postfix/virtual
# service postfix reload

Postfix Mail Forwarding Domains For Backup MX Server

If your server is a backup mx with relay domain configured via mysql / ldap proxy map only add virtual_alias_maps = hash:/etc/postfix/virtual to file. Create /etc/postfix/virtual file as described. In other words do not list domain in BOTH virtual_alias_domains and relay_domains. Use only one configuration option. Usually, relay_domains is configured for backup postfix MX servers.

Please note that you can also use procmail to forward email to another account.

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Leave a Reply

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

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts