Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
laravel 5.5无法使用gmail发送电子邮件_Laravel - Fatal编程技术网

laravel 5.5无法使用gmail发送电子邮件

laravel 5.5无法使用gmail发送电子邮件,laravel,Laravel,Windows 10、Apache httpd 2.4、PHP 7.1.4、Laravel 5.5 Gmail不太安全是允许的 My.env文件: MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=465 MAIL_USERNAME=account@gmail.com MAIL_PASSWORD=password MAIL_ENCRYPTION=ssl 错误消息: 无法与主机smtp.gmail.com建立连接 错误消息: 流\u套接字

Windows 10、Apache httpd 2.4、PHP 7.1.4、Laravel 5.5
Gmail不太安全是允许的


My.env文件:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=account@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
错误消息:
无法与主机smtp.gmail.com建立连接


错误消息:
流\u套接字\u启用\u加密():SSL操作失败,代码为1。OpenSSL错误消息:\n
错误:14090086:SSL例程:ssl3\u获取\u服务器\u证书:证书验证失败


我也试过了

MAIL_DRIVER=sendmail 
错误消息:
无法启动进程


有人说我的问题与这个问题重复:

但是这个问题,没有答案被接受,所有的答案都不起作用。 我加了一个回复,说我遇到的问题,然后有人说回复应该是答案,我的回复不是答案。我应该问一个新问题。在那个问题上,我的回答被删除了

以下是我所做的:(韦比宁的回答)
普特·卡塞特·佩姆

/vendor/guzzlehttp/guzzle/src/cacert.pem  
编辑Client.php

/vendor/guzzlehttp/guzzle/src/Client.php

private function configureDefaults(array $config)
{
    echo "<pre>", print_r(123, 1), "</pre>"; exit;

    $defaults = [
        'allow_redirects' => RedirectMiddleware::$defaultSettings,
        'http_errors'     => true,
        'decode_content'  => true,
        //'verify'          => true,
        'verify'          => dirname(__FILE__).'/cacert.pem',
        'cookies'         => false
    ];

答案是guzzlehttp,但我的错误信息是swiftmailer。Laravel现在使用不同的软件包

我找到了解决办法。不需要更改guzzle http/guzzle/src/Client.php,这是在另一个问题中建议的

解决方案:


  • 把cacert.pem放在你喜欢的地方

  • 编辑php.ini

  • 两行:

  • 重新启动apachehttpd

  • 如果smtp.gmail.com等重要域的证书验证失败,请检查此项。我怀疑有人劫持了您的DNS。您的答案中可能存在重复的@Webinion,但此项无效。请看我编辑的问题。
    /vendor/guzzlehttp/guzzle/src/Client.php
    
    private function configureDefaults(array $config)
    {
        echo "<pre>", print_r(123, 1), "</pre>"; exit;
    
        $defaults = [
            'allow_redirects' => RedirectMiddleware::$defaultSettings,
            'http_errors'     => true,
            'decode_content'  => true,
            //'verify'          => true,
            'verify'          => dirname(__FILE__).'/cacert.pem',
            'cookies'         => false
        ];
    
    Swift_TransportException   
    Connection could not be established with host smtp.gmail.com [ #0]
    
    D:\www\...\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php
    
    if (false === $this->stream) {
        throw new Swift_TransportException(
            'Connection could not be established with host '.$this->params['host'].
            ' ['.$errstr.' #'.$errno.']'
            );
    }
    
    curl.cainfo=D:/Servers/php/sslfiles/cacert.pem  
    openssl.cafile=D:/Servers/php/sslfiles/cacert.pem