You can configure Linux servers to make them send emails to administrators to alert them about the status of the system (logwatch, crontab, etc.). This feature is disabled by default. In this tutorial, we will show you how to enable it.
Get Started
To be able to receive system emails, you need first to edit the /etc/aliases file, then add your email address at the end:

# Person who should get root's mail
root: address@domain.com

Replace address@domain.com with your own email address.

Run then this command to confirm the changes you have made (this will recreate the /etc/aliases.db file):


All system emails will now be redirected to your email account. You should know that these emails will not arrive into your email inbox if there is no mail server installed in your system. I recommend to use sendmail (SMTP server).

To install sendmail on a Debian-based distribution, launch the terminal, and run these command:

sudo apt-get install sendmail
update-rc.d sendmail defaults
/etc/init.d/sendmail start 

For an RPM-based distribution, run these commands:

yum install sendmail
chkconfig sendmail on
/etc/init.d/sendmail start 

You can then verify if the emails are working by using this command:

echo -e "To: address@domain.com\nSubject: Test\nTest\n" | sendmail -bm -t -v  

Email sending errors can be viewed in this file: /var/log/maillog, consult it in case of problems.

Post a Comment