douhuigan8063 2015-05-29 15:15
浏览 38
已采纳

PHPMailer使用gmail

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. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

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: https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2

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 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多