openDKIM 中断电子邮件转发

openDKIM 中断电子邮件转发

将我们的服务器移至 Postfix 后,我决定使用 OpenDKIM 实现 DKIM。我已成功安装并运行它,但当它作为邮件过滤器启用时,服务器上的所有邮件转发功能都会中断。

例如,如果我在[电子邮件保护]并将其设置为转发到另一个地址(外部和内部受到同等影响),原始发件人收到类似以下消息:

This is the mail system at host server.example.com.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

    The mail system

<[email protected]>: Command rejected

Final-Recipient: rfc822; [email protected]
Action: failed
Status: 5.7.1
Diagnostic-Code: X-Postfix; Command rejected

有人有什么建议或经验吗?我对 qMail 相当熟悉,但对 Postfix 的经验并不多,而且由于这是生产服务器,我宁愿在没有建议的情况下破坏一切。

注释掉以下几行后,问题得到解决 /etc/postfix.main.cf

### custom ###
# OpenDKIM
#milter_default_action = accept
#milter_protocol = 6
#smtpd_milters = , inet:127.0.0.1:8891, inet:127.0.0.1:12768
#non_smtpd_milters = , inet:127.0.0.1:8891, inet:127.0.0.1:12768

以下是相应的邮件日志错误(当/etc/postfix.main.cf上述代码取消注释时就会出现这些错误):

Sep  8 10:09:09 server postfix/cleanup[24811]: BD99260811C5: milter-reject: END-OF-MESSAGE from localhost[127.0.0.1]: 5.7.1 Command rejected; from=<[email protected]> to=<[email protected]>
Sep  8 10:09:09 server postfix/cleanup[24811]: BD99260811C5: to=<[email protected]>, relay=none, delay=0.22, delays=0.22/0/0/0, dsn=5.7.1, status=bounced (Command rejected)

这里分别监听端口 8891 和 12768 的服务。

[root@server ~]# netstat -anp|grep :8891
tcp     0   0 127.0.0.1:8891     0.0.0.0:*   EN      25137/opendkim
[root@server ~]# netstat -anp|grep :12768
tcp     0   0 127.0.0.1:12768    0.0.0.0:*   EN      33037/psa-pc-remote

完整的配置文件 opendkim.conf 可以在以下位置找到:这里。下面的代码是它的精简版本。

$ egrep -v '^#' opendkim.conf | egrep -v '$^'
PidFile /var/run/opendkim/opendkim.pid
Mode    sv
SendReports yes
SoftwareHeader  yes
Canonicalization    relaxed/relaxed
Selector    default
MinimumKeyBits  1024
KeyFile /etc/opendkim/keys/default.private
Syslog yes
SyslogSuccess yes
LogWhy yes
UMask 002
OversignHeaders From
KeyTable refile:/etc/opendkim/KeyTable
SigningTable refile:/etc/opendkim/SigningTable
ExternalIgnoreList /etc/opendkim/TrustedHosts
InternalHosts /etc/opendkim/TrustedHosts
SignatureAlgorithm rsa-sha256
AutoRestart Yes
UserID opendkim:opendkim
Socket inet:8891@localhost

答案1

据我所知,您的邮件被拒收是因为您的某个邮件过滤程序无法处理 postfix 的命令。这不是 postfix 的问题,而是您的某个邮件过滤程序运行不正常。

在您的配置文件中,定义了两个过滤器:

  • 一个端口 8891,即 opendkim
  • 一个端口 12768,即 psa-pc-remote

请注意,这两个过滤器是累积的,我们实际上并不知道哪一个导致失败。但是,我认为可能是后者,因为你似乎不是第一个遇到问题的人。请参阅这个问题例如。

除非您出于某种原因需要 psa-pc-remote,否则您可以考虑禁用此过滤器并仅保留 opendkim。否则,解决方案超出了我的专业范围,我只能建议您在问题中添加 plesk 标签并尝试联系 plesk 的支持。

相关内容