防止向 root@domain 发送电子邮件

6 exim

我正在运行 Ubuntu Server 12.04 作为 Web 服务器并使用 Exim4 发送确认电子邮件等。有没有办法为 root 用户设置系统范围的电子邮件地址?换句话说,我希望所有电子邮件都转到不同的地址,而不是 root@domain.com。例如,这个命令...

echo "test" | mail -v -s test root
Run Code Online (Sandbox Code Playgroud)

...将转到不同的地址,以及 root 执行的所有 cron 任务:

# 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 )
Run Code Online (Sandbox Code Playgroud)

d4v*_*0rk 6

您可以编辑 /etc/aliases 并查找以以下内容开头的行:root:

或添加一个。可能会被注释掉。然后按照 MTA 的说明重新加载配置。对于 Exim 4,您实际上不必重新启动它,但是在运行 Postfix(Ubuntu 的默认 MTA)时,您需要运行newaliases.

或在 /root/.forward 中更新