How to forward mails for root to external email address using Postfix in Plesk environment

I am running Centos 5 with Parallels Plesk Panel 10.3.1. My MTA is Postfix. I was looking for some solution to forward all the mails for user root to some external email address. Follow these steps at your own risk to achieve this.

Plesk stores the mail aliases database in /var/spool/postfix/plesk/aliases.db file. If this is the first time you are browsing the folder /var/spool/postfix/plesk then you will not find the file named aliases but instead you will find aliases.db file. These db files are binary files so you need to have some tool to decode this file to text format ; make the changes in the text file and convert it back to the database file.

Go to /var/spool/postfix/plesk/ folder and issue the following command to convert the aliases.db file to text format. Here, you don’t have to specify aliases file with .db extension.

# postmap –s aliases > aliases

Now edit /var/spool/postfix/plesk/aliases file and make the appropriate change to forward mails for root to the external email address. This file will look like below:

postmaster abc@example.com
root def@example.com
mailer-daemon abc@example.com
anonymous abc@example.com
mailman abc@example.com

After making the necessary changes, save the aliases file. Now you need to convert the text file aliases to aliases.db file. Stay in the folder /var/spool/postfix/plesk and issue the following command to do so.

# postmap hash:aliases

Now, that the aliases.db file has been generated, you need to tell postfix daemon to reload the configuration. Issue the following command:

# postfix reload

Trigger an email to xyz@localhost.localdomain and check if it has been forwarded to def@example.com.

2 thoughts on “How to forward mails for root to external email address using Postfix in Plesk environment”

  1. hi,
    I am a linux newbie, good to see that there exists at least a linux users site here in Nepal. First of all i apologize for posting here in the bjog post reply but i looked at he whole site and could not find any way to signup/join or whatever. Is it because i use a mobile phone to surf the net? I think it would be great if there was a way to post article on the homepage or wherever. I have a lot to learn about linux and i need your assistance. I am looking for you to notice this.

    thanks in advance 🙂

Leave a Reply

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


*