![Postfix/OpenDKIM 未对 PHP 发送的电子邮件进行签名](https://linux22.com/image/651824/Postfix%2FOpenDKIM%20%E6%9C%AA%E5%AF%B9%20PHP%20%E5%8F%91%E9%80%81%E7%9A%84%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6%E8%BF%9B%E8%A1%8C%E7%AD%BE%E5%90%8D.png)
我们安装了 SPF、DKIM 和 DMARC 记录以确保电子邮件安全/可验证性。
通过控制台或邮件客户端(例如 Outlook 或 Mac 的 Mail)发送时,它会进行全面处理,并且所有三个都会通过。
通过 Zend Framework 1.12 的 SendMail 函数发送时失败(php)。
我们是否错过了某个配置,导致 php 电子邮件也签名了?我们要查看哪个文件?还是必须有不同的安装/附加组件?
我们在 Cent OS 6 上使用 OpenDKIM 和 Postfix
postfix -n 结果:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
milter_default_action = accept
milter_protocol = 2
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
mydomain = example.com
myhostname = server1.example.com
mynetworks = 127.0.0.0/32
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
non_smtpd_milters =
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_milters = inet:localhost:8891
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/mail.example.com.crt
smtpd_tls_key_file = /etc/pki/tls/private/mail.example.com.key
smtpd_tls_loglevel = 1
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
virtual_transport = dovecot
这是我从 Port25 电子邮件检查器获得的结果。除了 zend 时缺少 DKIM 外,其他都一样。
非 Zend 常规标头: DKIM 签名
Return-Path: <[email protected]>
Received: from server1.example.com (123.123.123.123 (my server ip)) by verifier.port25.com id hrh7ri20i3gm for <[email protected]>; Thu, 12 Feb 2015 02:01:13 -0500 (envelope-from <[email protected]>)
Authentication-Results: verifier.port25.com; spf=pass [email protected]
Authentication-Results: verifier.port25.com; domainkeys=neutral (message not signed) [email protected]
Authentication-Results: verifier.port25.com; dkim=pass (matches From: [email protected]) header.d=example.com
Authentication-Results: verifier.port25.com; sender-id=pass [email protected]
Received: from [111.111.1.111] (cpe-11-11-111-111.socal.res.rr.com [76.94.200.240])
by server1.example.com (Postfix) with ESMTPSA id 33F233800A9
for <[email protected].>; Wed, 11 Feb 2015 23:01:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=example.com;
s=default; t=1423724471;
bh=qMnrIAg7afoneBTtI0hU9OrDkqChYZOD1f4AUvZtdGw=;
h=From:Subject:Date:To;
b=g4lXm/vQ54wq/B0fCAf/U3Hj3hi2N2jojst+5lURCfykwhvzjqCm/Z5VGz3rcu
MoZCfxEkCI4OyQqW2kch93h93h93j3kbuCg3Pehl2WlgoLJy2S8CMR68ygNU52+P88
IG/vq2YShK6ctLUxRq4O79IYzKcInRiXuWOtuV3A=
From: Darius <[email protected]>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Subject: Give me a test result. Thank you.
Message-Id: <[email protected]>
Date: Wed, 11 Feb 2015 23:01:00 -0800
To: [email protected].
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\))
X-Mailer: Apple Mail (2.2070.6)
这是 Zend 版本的 Headers 结果: 不是DKIM 签名
Return-Path: <[email protected]>
Received: from server1.example.com (xxx.xxx.xxx.xxx (my server ip)) by verifier.port25.com id hr9du620i3gl for <[email protected]>; Tue, 10 Feb 2015 14:28:35 -0500 (envelope-from <[email protected]>)
Authentication-Results: verifier.port25.com; spf=pass [email protected]
Authentication-Results: verifier.port25.com; domainkeys=neutral (message not signed) [email protected]
Authentication-Results: verifier.port25.com; dkim=neutral (message not signed)
Authentication-Results: verifier.port25.com; sender-id=pass [email protected]
Received: by server1.example.com (Postfix, from userid 500)
id 08E073800AA; Tue, 10 Feb 2015 11:28:25 -0800 (PST)
To: [email protected]
Subject: mydomain Test
X-PHP-Originating-Script: 5004:Sendmail.php
From: mydomain Test <[email protected]>
Date: Tue, 10 Feb 2015 11:28:24 -0800
Content-Type: multipart/alternative;
boundary="=_af78e87ff18206603cb724d073777150"
MIME-Version: 1.0
Message-Id: <[email protected]>
答案1
通过控制台或邮件客户端(例如 Outlook 或 Mac 的 Mail)发送时,它会进行全面处理,并且所有三个都会通过。
此行为是预期行为,因为您将此配置放在main.cf
smtpd_milters = inet:localhost:8891
通过 Zend Framework 1.12 的 SendMail 函数发送时失败(php)。
此行为也是预料之中的,因为您将此配置放在main.cf
non_smtpd_milters =
解释
默认情况下,OpenDKIM 与 postfix 结合使用,米尔特. 启用/禁用 milter 应用程序由smtpd_milters
和non_smtpd_milters
参数。对于通过 smtpd 发送邮件的应用程序,对应的参数为smtpd_milters
,对于 sendmail ,对应的参数为non_smtpd_milters
解决方案
non_smtpd_milters =
用。。。来代替
non_smtpd_milters = inet:localhost:8891