I am running a Postfix with Dovecot for my emails and also make email accounts for my friends from time to time. So last night a friend of mine asked me to configure an email account for him and forward the emails to his gmail account. It is really easy and quick to Configure Postfix Mail Forward and this is why i decided to share it with my readers in case anyone else happens to need it. Read this post to learn how to Configure Postfix Mail Forward. If you would like to learn to configure Postfix with Dovecot on CentOS linux read my post HERE.
Let’s Configure Postfix Mail Forward!
1. Check Postfix Main Configuration File
You must check Postfix main configuration file located at “/etc/postfix/main.cf” to make sure Postfix virtual mappings are enabled.
You can see this by searching for “virtual_alias_maps”. You should see something like this:
virtual_alias_maps = hash:/etc/postfix/virtual
Note the file “virtual_alias_maps” are pointing to – in my case it is “/etc/postfix/virtual”.
2. Edit “virtual_alias_maps”
The “virtual_alias_maps” file is where you can add the desired mailbox forwards. You can do this by adding the local recipient email address – the email address that exists on your Postfix server – followed by the email address you would like to forward emails.
The following line forwards emails sent to email@example.com to firstname.lastname@example.org :
3. Postmap “virtual_alias_maps”
To finish up you need to postmap “virtual_alias_maps” as follows:
[root@geekpeek ~]# postmap /etc/postfix/virtual
4. Restart Postfix Service
After making any changes to Postfix configuration a service restart is necessary. You can restart Postfix service with the following command:
[root@server ~]# service postfix restart Shutting down postfix: [ OK ] Starting postfix: [ OK ]
Voila, you can now test your configuration by sending an email to email@example.com and it should be forwarded to firstname.lastname@example.org.