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:

cd /etc
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
Подписаться на IT Blog (RU) по Email
Subscribe to IT Blog (EN) by Email

Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a Reply