Redirecting mail for the root user

Open the aliases in the text editor:

sudo nano /etc/aliases

Example of redirecting the root mail to admin@example.net:

root: admin@example.net

You can forward directly to several addresses:

root: admin@example.net,user@example.net

Press Ctrl+O then Enter and Ctrl+X to exit the nano editor.

For the changes to take effect, you must update the alias database with the command:

sudo newaliases

For exim with cPanel, update this with:

exim -bi

If postfix is used as the mail sending server, then the /etc/postfix/main.cf config file can specify other paths to the list and the alias base, for example:

alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases

In this case, edit this file too:

sudo nano /etc/postfix/aliases
cd /etc/postfix/aliases
sudo newaliases
sudo service postfix restart

For verification, you can send an email to the user as root:

echo 'Test' | mail -s Test root

Se also my article:
Solution of the warning “database /etc/aliases.db is older than source file /etc/aliases”

Leave a comment

Leave a Reply