Applications such as Apache or a cron daemon often need to send mail to users (often the root user) to inform them of an error or simple operations. When a system is not properly configured to relay these emails some problems may arise which might not get noticed. For example, a job is set up in a cron daemon that outputs some sort of message. What the cron will do (by default) is send an email to root@localhost. However, because root@localhost is not a real email address, the email will be sent out to no one knows where and bounce. The bounced email will most likely make its way to your ISP's servers (or other email servers on its way). This mini-guide explains how to configure your machine to make such emails come to you rather than strangers.
Use your favorite editor and open up
Open /etc/mail/aliases. # nano -w /etc/mail/aliases
You only need to make two changes:
# Basic system aliases -- these MUST be present. MAILER-DAEMON: postmaster postmaster: root # General redirections for pseudo accounts. adm: root bin: root daemon: root exim: root lp: root mail: root named: root nobody: root postfix: root # Well-known aliases -- these should be filled in! root: [Put your email here] operator: [Put your email here] # Standard RFC2142 aliases abuse: postmaster ftp: root hostmaster: root news: usenet noc: root security: root usenet: root uucp: root webmaster: root www: webmaster # trap decode to catch security attacks # decode: /dev/null
That is it. Now all applications that need to send emails to any of the users above will email to you.