【问题标题】:PHPMailer smtp connection failed on server服务器上的 PHPMailer smtp 连接失败
【发布时间】:2018-05-28 12:06:26
【问题描述】:

我正在使用 PHPMailer 类从我的网站发送一封电子邮件,它在本地运行良好,但在我的在线服务器上出现错误:

2018-05-28 12:03:40 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array()
2018-05-28 12:03:40 Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [/home/beesystems/public_html/specs/vendor/phpmailer/phpmailer/src/SMTP.php line 325]
2018-05-28 12:03:40 Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [/home/beesystems/public_html/specs/vendor/phpmailer/phpmailer/src/SMTP.php line 325]
2018-05-28 12:03:40 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [/home/beesystems/public_html/specs/vendor/phpmailer/phpmailer/src/SMTP.php line 325]
2018-05-28 12:03:40 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

代码:

            $mail = new PHPMailer();
            $mail->IsSMTP();
            $mail->SMTPAuth = true;
            $mail->SMTPSecure = 'ssl';
            $mail->Host = "smtp.gmail.com";
            $mail->Port = 465;

           $mail->Username = \Yii::$app->params['mailer-account'];
           $mail->Password = \Yii::$app->params['mailer-password'];

【问题讨论】:

标签: php ssl yii2 smtp phpmailer


【解决方案1】:

这是重要的部分:

SSL 例程:ssl3_get_server_certificate:certificate verify failed

这在错误消息链接的故障排除指南中得到了广泛的介绍,并且已在此处多次回答。在端口 587 上将 SMTPSecure 切换为 tls 将无济于事。很可能您的服务器运行的是旧版本的 PHP,或者具有过时的 CA 证书包。

【讨论】:

    猜你喜欢
    • 2015-09-25
    • 2019-07-23
    • 2014-06-13
    • 2015-08-09
    • 1970-01-01
    • 2016-06-12
    • 2016-11-10
    • 2014-05-20
    • 1970-01-01
    相关资源
    最近更新 更多