douhuigan8063 2015-05-29 15:15
浏览 38


I'm trying to send emails using PHPMailer and Gmail. It worked fine on PHP 5.5 but when I updated to php 5.6 I get this error (tls on port 587): stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

If I try using ssl on port 465 I get this instead: 2015-05-29 15:11:58 SMTP ERROR: Failed to connect to server: (0) 2015-05-29 15:11:58 SMTP connect() failed.

I googled around and the only thing I found out is that I should set up OAUTH2 but I don't know how. I googled around for that as well and found this:

I followed that and got stuck when they said that I should update get_auth_token.php. I can't find this file anywhere. This is how I installed phpmailer using composer: "phpmailer/phpmailer": "~5.2"

Do anyone know how to get it working with or without OAUTH2? I'm using php 5.6.8

Thanks in advance, Busarna4

  • 写回答

1条回答 默认 最新

  • dskyx46424 2015-05-29 15:23

    PHP 5.6 introduces SSL certificate verification, So if your config is broken, it will fail with this SSL3_GET_SERVER_CERTIFICATE:certificate verify failed error. You should fix your SSL, but you can revert to the old behavior by overriding PHP MAILER and passing these options to the smtpConnect function like this way.

    $options = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true

    @Courtesy Synchro

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



    • ¥15 怎么使请求通过cors
    • ¥15 WDM 驱动ACPI 相关疑问
    • ¥15 prism 跨窗体共享数据绑定 wpf
    • ¥15 hdl designer突然用不了系统的moduleware组件,请问有人遇到或者怎么解决吗?
    • ¥15 0基础计算机毕设,应该从哪开始?
    • ¥60 使用DKT40脑图划分ROI区域
    • ¥15 有偿解决C51单片机液晶屏12864显示问题
    • ¥15 IDEA构建失败?怎么搞
    • ¥15 求该题的simpson,牛顿科特斯matlab代码,越快越好
    • ¥35 如何编译arm板子的gcc