错误信息:
SSL报错信息
Connection could not be established with host ... [ #0]
TLS报错信息
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
解决方法
由于Yii2使用swiftmailer较低所以,需要先更新版本。
composer require swiftmailer/swiftmailer
添加streamOptions配置
'mailer' => [
// ...
'transport' => [
'class' => 'Swift_SmtpTransport',
// ...
// 添加配置
'streamOptions' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
// ...
]
// ...
],