Postfix

openDKIM 中斷電子郵件轉發

  • September 10, 2015

在將我們的伺服器移到 Postfix 之後,我決定使用 OpenDKIM 實現 DKIM。我已經成功地安裝和執行了它,但是當它作為一個 milter 啟用時,伺服器上的所有郵件轉發都被破壞了。

例如,如果我在 james@example.com 下創建一個郵箱並將其設置為轉發到另一個地址(外部和內部同樣受到影響),則原始發件人收到類似於以下消息的消息:

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

<accounttobeforwardedto@example.com>: Command rejected

Final-Recipient: rfc822; accounttobeforwardedto@example.com
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=<originalsender@gmail.com> to=<forwardaddress@gmail.com>
Sep  8 10:09:09 server postfix/cleanup[24811]: BD99260811C5: to=<forwardaddress@gmail.com>, 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

據我所知,您的郵件似乎被拒絕,因為您的一個 milter 未能處理 postfix 的命令。這不是 postfix 的問題,而是您的一個 milter 行為不正常。

在您的 conf 中,定義了兩個 milter:

  • 一一埠8891,即opendkim
  • 一一埠12768,即psa-pc-remote

請注意,這兩個 milter 是累積的,我們實際上並不知道是哪一個導致了失敗。但是,在我看來,它很可能是後者,因為您似乎不是第一個遇到問題的人。例如看這個問題

除非出於某種原因需要 psa-pc-remote,否則可以考慮禁用此 milter 並僅保留 opendkim。否則,解決方案超出了我的專業領域,我只能建議您在您的問題中添加一個 plesk 標籤並嘗試聯繫 plesk 的支持。

引用自:https://serverfault.com/questions/720657