邮件发送不出去,用命令行测试一下:telnet 127.0.0.1 25,结果提示:421 Unexpected failure, please try later,中文为:SMTP 错误 (421):连接服务器失败
root@debian:~# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
421 Unexpected failure, please try later
接下来查看下exim4日志,tail -f /var/log/exim4/mainlog,结果显示:failed to open /etc/exim4/spam-blocks.conf for linear search: Permission denied (euid=108 egid=115)
SMTP command timeout on connection from localhost.localdomain [127.0.0.1]
很明显,/etc/exim4/spam-blocks.conf文件的权限错误,运行命令 ls -l /etc/exim4/spam-blocks.conf
检查该文件的拥有者和权限设置是否正确。它应该属于 root 用户,且具有至少 644 的权限。
- 更改文件权限: 如果文件不属于 root 用户或没有正确的权限,您可以使用
chown
和chmod
命令更改它们。例如,运行以下命令以将文件所有权更改为 root 用户,并将权限设置为 644:
sudo chown root:root /etc/exim4/spam-blocks.conf
sudo chmod 644 /etc/exim4/spam-blocks.conf
这样设置后,再重新使用命令行telnet 127.0.0.1 25测试就没报错啦。
root@debian:~# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 debian.example.com ESMTP Exim 4.94.2 Sun, 19 Mar 2023 11:56:29 -0400
拓展阅读:
如果tail -f /var/log/exim4/mainlog
,结果显示:failed to open /etc/exim4/deny_senders when checking "/etc/exim4/deny_senders": Permission denied (euid=110 egid=117)
,同样,文件“/etc/exim4/deny_senders”的权限设置错误。它应该属于 root 用户,且具有至少 644 的权限,运行如下命令修改权限。
sudo chown root:root /etc/exim4/deny_senders
sudo chmod 644 /etc/exim4/deny_senders