Prevent email to root@domain

6

I'm running Ubuntu Server 12.04 as a web server and use Exim4 for sending confirmation emails and such. Is there a way to set a system-wide email address for the root user? In other words, I'd like ALL email to go to a different address rather than root@domain.com. For example, this command...

echo "test" | mail -v -s test root

...would go to a different address, as well as all cron tasks that root executes:

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

user157635

Posted 2012-09-11T15:06:07.063

Reputation:

Answers

6

you can edit /etc/aliases and look for the line starting with: root:

or add one. It might be commented out. Then follow the instructions for your MTA to reload the configuation. For Exim 4 you don't have to restart it actually, but when running Postfix (Ubuntu's default MTA) you'll need to run newaliases.

or update it in /root/.forward

d4v3y0rk

Posted 2012-09-11T15:06:07.063

Reputation: 1 187

I don't have sendmail installed. Would I need to restart anything if I just edit /root/.forward? – None – 2012-09-11T15:16:16.770

nope, you would not need to restart anything. – d4v3y0rk – 2012-09-11T15:19:39.853

4

In the root account home folder add a ".forward" file that contains the e-mail address or alternate account name on that system for where you want e-mail to be redirected to.

So, make a file named ".forward" containing one line that reads either:

name@domain

or simply:

name

I hope that is clear enough. All e-mail coming into root should automatically be forward to to the other mailbox.

Bryan C.

Posted 2012-09-11T15:06:07.063

Reputation: 226

From searching, the .foward appears to be part of sendmail. Is there a different configuration needed for exim? – None – 2012-09-11T15:30:01.353

This doesn't work on my system. Not sure what I'm missing. – None – 2012-09-11T16:04:29.860

Hmm... strange. You mentioned you don't have sendmail installed. I'm curious why not? That's probably the problem. – Bryan C. – 2012-09-11T16:06:43.583

It's close to stock install of Ubuntu. Any reason I need sendmail in addition to exim? I thought they were accomplishing the same task. – None – 2012-09-11T16:25:01.363

Hmm... sorry. That I don't know. I always run sendmail on my servers. Maybe someone else can chime in on that question. – Bryan C. – 2012-09-11T16:30:28.580