【问题标题】:SSL error in Laravel 5.2 [duplicate]Laravel 5.2 中的 SSL 错误 [重复]
【发布时间】:2016-12-24 19:46:43
【问题描述】:

我无法在 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

这是我的 .env 文件

MAIL_DRIVER=smtp
MAIL_HOST=smtp-relay.gmail.com
MAIL_PORT=587
MAIL_USERNAME=**********@gmail.com
MAIL_PASSWORD=*********
MAIL_ENCRYPTION=ssl

文件mail.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',
];

我研究了几个小时,但无法解决这个问题,有什么建议吗? P/S:我使用 Windows 10 和 XAMPP 作为 Web 服务器

【问题讨论】:

  • 您是否尝试过使用tls 加密而不是ssl

标签: php laravel email gmail


【解决方案1】:

.env 文件中的更改:

MAIL_DRIVER=smtp 到 MAIL_DRIVER=mail

【讨论】:

【解决方案2】:

这里有两种可能的解决方案: 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

这两行基本上可以帮助您创建默认文件夹并从 curl.haxx.se 导入最新的证书存储。 如果有兴趣,这是我得到的源文章:https://andrewyager.com/2016/10/04/php-on-macos-sierra-cant-access-ssl-data/comment-page-1/#comment-52

希望对您有所帮助。

【讨论】:

  • @AlonfromDataPlusResearch 好,我的回答对你很有用,赞成票将被占用。
【解决方案3】:

在你的配置文件中

主机应该是 smtp.gmail.com From 和 name 不应为空 将您的邮件加密从 ssl 更改为 tsl

不要忘记在您的 Google 帐户设置中打开安全性较低的应用

【讨论】:

    【解决方案4】:

    转到位置 \vendor\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php 在第 259 行并注释以下内容:

    //$options = array();

    并添加。

    $options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true);

    【讨论】:

    • “vendor”目录中的文件不可编辑。如果您认为有错误,请分叉该存储库并将拉取请求发送到 main。
    猜你喜欢
    • 1970-01-01
    • 2016-08-06
    • 2016-05-25
    • 2016-04-25
    • 1970-01-01
    • 1970-01-01
    • 2016-03-28
    • 2016-06-11
    • 2016-10-21
    相关资源
    最近更新 更多