Linux:忽略别名文件中的条目

Linux:忽略别名文件中的条目

我正在尝试配置我的 RHEL6.5 服务器,将所有发往 root 或 apache 的电子邮件发送到我的外部电子邮件地址。我找到了很多关于如何执行此操作的指南,并尝试了所有我能找到的建议,包括使用虚拟域重定向……但我相信“正确”的方法是使用别名文件。然而,什么都不起作用!目前,我的 /etc/aliases 文件配置了以下行:

root:    [email protected]
apache:  [email protected]

但是,当我运行“newaliases”,重新启动 sendmail/postfix,然后发送测试电子邮件时,它仍尝试发送到 root@localhost 或 apache@localhost,但失败。

对于我正在做的事情,我遇到的最完整/最清晰的指南是这里:http://blog.bobbyallen.me/2013/02/03/how-to-redirect-local-root-mail-to-an-external-email-address-on-linux/

如果您有任何想法,请告诉我。

sendmail -d27.2 -bv root 和 sendmail -d27.2 -d44.4 -bv root 的输出是......

请注意,我确实将一些输出参数修改为通用的,而不是使用我的实际信息。(例如我的主机名等等)

            [root@domain-sys ~]# sendmail -d27.2 -bv root
            alias(root)
            root (, root) aliased to [email protected]
            self_reference([email protected])
                    ... no self ref
            [email protected]... deliverable: mailer esmtp, host email.com., user [email protected]
            [root@domain-sys ~]#
            [root@domain-sys ~]# sendmail -d27.2 -d44.4 -bv root
            safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
                    [dir /etc/mail] OK
                    No such file or directory
            safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
                    [dir /etc/mail] OK
                    No such file or directory
            safefile(/etc/mail/sendmail.cf, uid=0, gid=0, flags=6000, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6000, level=0, offset=0):
                    [dir /etc/mail] OK
                    [uid 0, nlink 1, stat 100644, mode 400]         OK
            safefile(/etc/mail/local-host-names, uid=0, gid=0, flags=6580, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
                    [dir /etc/mail] OK
                    [uid 0, nlink 1, stat 100644, mode 400]         OK
            safefile(/etc/mail/relay-domains, uid=0, gid=0, flags=6580, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
                    [dir /etc/mail] OK
                    No such file or directory
            safefile(/etc/mail/trusted-users, uid=0, gid=0, flags=6580, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
                    [dir /etc/mail] OK
                    [uid 0, nlink 1, stat 100644, mode 400]         OK
            safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
                    [dir /etc/mail] OK
                    No such file or directory
            safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
                    [dir /etc/mail] OK
                    No such file or directory
            safedirpath(/var/spool/mqueue, uid=0, gid=0, flags=4, level=0, offset=0):
                    [dir /var/spool/mqueue] OK
            alias(root)
            safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
                    [dir /etc/mail] OK
                    No such file or directory
            safefile(/etc/aliases.db, uid=0, gid=0, flags=584, mode=400):
            safedirpath(/etc, uid=0, gid=0, flags=584, level=0, offset=0):
                    [dir /etc] OK
                    [uid 0, nlink 1, stat 100644, mode 400]         OK
            root (, root) aliased to [email protected]
            safefile(/etc/mail/mailertable.db, uid=0, gid=0, flags=584, mode=400):
            safedirpath(/etc/mail, uid=0, gid=0, flags=584, level=0, offset=0):
                    [dir /etc/mail] OK
                    [uid 0, nlink 1, stat 100640, mode 400]         OK
            self_reference([email protected])
                    ... no self ref
            [email protected]... deliverable: mailer esmtp, host email.com., user [email protected]

答案1

步骤 1-测试别名处理:
以 root 身份执行以下测试命令
(仅当第一个命令出现问题时才使用第二个命令):

sendmail -d27.2 -bv root
sendmail -d27.2 -d44.4 -bv root

它应该可以帮助您排除或找到一些最可能的原因,例如:

  • sendmail 在不同位置寻找别名文件(例如 /etc/mail/aliases )
  • 由于广泛的写入权限,sendmail 忽略别名文件

第 2 步——测试外部交付:
以 root 身份执行以下测试命令,以详细模式发送测试消息:

(echo Subject: test; echo) | sendmail -v root

它应该可以帮助您排除或找到一些最可能的原因,例如:

  • 发件人域无效(拒绝“MAIL FROM:”)
  • 由于主机被公共或私人 DNSBL 列出而拒绝

相关内容