Generic placeholder image
闲敲代码、落灯花
What's past is prologue

联系邮箱:email@hezehua.net


联系QQ:1907330840

座右铭

保持热情,持续学习,每日精进

Laravel 发送邮件报错的解决方案:PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1.

Laravel 发送邮件报错的解决方案:PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1.

本文与作者在csdn上的博文【Laravel 发送邮件报错的解决方案:PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1.】保持同步


在搭建好私人邮箱服务器后,正好做了一个共享主机的产品,就需要在申请共享主机后给用户发通知,遇到这个报错:

PHP Warning:  stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /data/www/blog/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 94

ssl 服务器证书校验失败,就是邮件服务器的证书可能有问题,解决办法有两种:

  1. 重新签发邮件服务器的ssl证书
  2. 不校验服务器证书

我选择第2种方式,因为懒得折腾…

  1. 找到这个文件:vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php

  2. 找到这个方法:establishSocketConnection

  3. 修改代码:

    
        ......
        //下面两句代码在stream_context_create之前加入
        $options['ssl']['verify _peer'] = FALSE;
        $options['ssl']['verify_peer_name'] = FALSE;
        ......
    
        $streamContext = stream_context_create($options);
    

解决。

猜你喜欢