php - 如何处理 Laravel 的 SMTP 驱动程序中的自签名 TLS 证书?

标签 php laravel email ssl self-signed-certificate

我正在尝试使用此配置发送电子邮件:

return [

    'driver'     => 'smtp',

    'host'       => 'mail.mydomain.com',

    'port'       => 26,

    'from'       => ['address' => 'mailer@mydomain.com', 'name' => 'Mailer'],

    'encryption' => 'tls',

    'username'   => env('MAIL_USERNAME'),

    'password'   => env('MAIL_PASSWORD'),

    'sendmail'   => '/usr/sbin/sendmail -bs',

    'pretend'    => false,

];

当我提交表单时收到此错误:

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

我找到了这个解决方案,人们似乎已经用同一个库解决了这个问题,但我无法在 Laravel 中解决它。

https://github.com/PHPMailer/PHPMailer/issues/368

最佳答案

Editor's note: disabling SSL verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a Man-in-the-Middle Attack.

Be sure you fully understand the security issues before using this as a solution.

在你的 config/mail.php 底部添加这个

'stream' => [
   'ssl' => [
       'allow_self_signed' => true,
       'verify_peer' => false,
       'verify_peer_name' => false,
   ],
],

这将解决您的问题。

关于php - 如何处理 Laravel 的 SMTP 驱动程序中的自签名 TLS 证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52931285/

相关文章:

php - php 中的 mysql 语法错误,输入 phpmyadmin 时工作正常

javascript - Jquery 不将 html 传递到 iframe

html - 如何链接 html 电子邮件中的 block 级元素?

C# 发送 HTML 和文本电子邮件 - 最优雅?

php - symfony 4 : Request. getScheme() 返回带有 X_FORWARDED_PROTO https 的 http

javascript - 谷歌图表、PHP 和 Ajax

laravel - 使用服务器 nginx 将所有请求重定向到 azure WebApp 中的文件夹/public

javascript - 从 Laravel 设置 cookie 并从 javascript 获取 null

javascript - 使用 PUT 方法 Angularjs 发送文件

android - 如何在 Android 上自动发送电子邮件?