【发布时间】:2018-03-07 15:02:43
【问题描述】:
我在尝试使用 PHPMailer 配置和发送邮件时收到以下警告:
PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
我查看了其他解决方案,但没有一个有效。以下是一些细节:
我的证书(来自letsencrypt)是有效的,至少在我的Nginx 配置中是这样。我的 WordPress 网站服务安全,没有错误。我的 PHP 版本是 7.0.xx
-
我尝试将证书文件位置添加到
php.ini,但它警告加载流失败,即使地址正确。这是我尝试过的(除其他外):openssl.capath = "/etc/letsencrypt/live/example.org/"这会导致 与上面完全相同的错误。我也试过:
openssl.cafile = "/etc/letsencrypt/live/example.org/fullchain.pem"但收到警告:PHP Warning:failed loading cafile stream
我的 PHP 邮件配置(位于我的 wordpress 函数文件中)如下所示:
$phpmailer->Host = 'mail.example.org';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 587;
$phpmailer->Username = 'myadminaccount@example.org';
$phpmailer->Password = 'mypassword';
$phpmailer->SMTPSecure = "tls";
$phpmailer->From = "myadminaccount@example.org";
$phpmailer->FromName = "MY Admin Account";
正如我所说,我已经尝试了网站上其他地方的各种解决方案,但都没有奏效。我很困惑,因为我的本地证书(以及邮件服务器的证书)都是有效的。
我真的不想像其他地方建议的那样关闭对等验证,但如果必须的话,我想我会的。
【问题讨论】:
-
您好,请问您使用的是哪个版本的 PHP?
-
如果 PHP 版本 >= 5.6 设置更改,如果您没有 stackoverflow.com/questions/31460941/… 问候,您可以在此处找到示例。
-
对不起,我应该提到它是 PHP 7.0,我会在上面添加它。
-
我相信 cacert 的正确变量不是“default_cert_file”,而是“ini_cafile”,让我们试试吧:)。
-
你能说得更具体些吗?尝试什么以及在什么文件中?