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 陆空双模式无人机怎么做
  • ¥15 想咨询点问题,与算法转换,负荷预测,数字孪生有关
  • ¥15 C#中的编译平台的区别影响
  • ¥15 软件供应链安全是跟可靠性有关还是跟安全性有关?
  • ¥15 电脑蓝屏logfilessrtsrttrail问题
  • ¥20 关于wordpress建站遇到的问题!(语言-php)(相关搜索:云服务器)
  • ¥15 【求职】怎么找到一个周围人素质都很高不会欺负他人,并且未来月薪能够达到一万以上(技术岗)的工作?希望可以收到写有具体,可靠,已经实践过了的路径的回答?
  • ¥15 Java+vue部署版本反编译
  • ¥100 对反编译和ai熟悉的开发者。
  • ¥15 带序列特征的多输出预测模型