Laravel 5.2 中的 SSL 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39008705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SSL error in Laravel 5.2
提问by end_lesslove2012
I was unable to send an email in laravel 5,when I click send it return this message
我无法在 Laravel 5 中发送电子邮件,当我单击发送时返回此消息
ErrorException in StreamBuffer.php line 95:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Here is my .env file
这是我的 .env 文件
MAIL_DRIVER=smtp
MAIL_HOST=smtp-relay.gmail.com
MAIL_PORT=587
MAIL_USERNAME=**********@gmail.com
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=ssl
file mail.php
文件邮件.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp-relay.gmail.comt'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => null, 'name' => null],
'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
I researched for hours but couldn't resolve this, any advice ? P/S: I use Windows 10 and XAMPP for Webserver
我研究了几个小时但无法解决这个问题,有什么建议吗?P/S:我使用 Windows 10 和 XAMPP 作为 Web 服务器
回答by Chintan Hingrajia
Change in .env
file:
.env
文件更改:
MAIL_DRIVER=smtp to MAIL_DRIVER=mail
MAIL_DRIVER=smtp 到 MAIL_DRIVER=mail
回答by Eazy
Here are two possible solutions: 1) Get rid of "tls" and leave MAIL_ENCRYPTION as blank. 2) If you are on MacOS Sierra and want to keep your 'tls' setting, type these two lines in your terminal/shall: $ sudo mkdir -p /usr/local/libressl/etc/ssl/certs $ sudo curl -o /usr/local/libressl/etc/ssl/cert.pem https://curl.haxx.se/ca/cacert.pem
这里有两种可能的解决方案:1) 去掉“tls”并将 MAIL_ENCRYPTION 留空。2) 如果您使用的是 MacOS Sierra 并且想要保留您的 'tls' 设置,请在您的终端/应输入以下两行: $ sudo mkdir -p /usr/local/libressl/etc/ssl/certs $ sudo curl -o /usr/local/libressl/etc/ssl/cert.pem https://curl.haxx.se/ca/cacert.pem
The two lines basically help you create the default folder and import the latest certificate store from curl.haxx.se. Here is the source article I got if interested: https://andrewyager.com/2016/10/04/php-on-macos-sierra-cant-access-ssl-data/comment-page-1/#comment-52
这两行基本上可以帮助您创建默认文件夹并从 curl.haxx.se 导入最新的证书存储。如果有兴趣,这是我得到的源文章:https: //andrewyager.com/2016/10/04/php-on-macos-sierra-cant-access-ssl-data/comment-page-1/#comment-52
Hope it helps.?
希望能帮助到你。?
回答by Matu95
Go to location \vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.phpat line 259 and comment the following:
转到 location \vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php第 259 行并注释以下内容:
//$options = array();
//$options = array();
and add.
并添加。
$options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true);
$options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true);
回答by afrasiyab haider
In your config file
在你的配置文件中
the host should be smtp.gmail.com From and name should not be null change your mail encryption from ssl to tsl
主机应为 smtp.gmail.com From 且名称不应为 null 将您的邮件加密从 ssl 更改为 tsl
dont forget to turn on less secure app in your google accout setting
不要忘记在您的谷歌账户设置中打开安全性较低的应用程序