Laravel Gmail 配置错误

Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
本文介绍了Laravel Gmail 配置错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Gmail 的 Laravel 电子邮件中遇到了这个问题,我已经检查并审查了 Stack Overflow 上的许多问题,但在我的情况下仍然没有一个问题.我正在使用 Laravel 5.4 和 Xampp.

I have been having this issue with Laravel email with Gmail and I have checked and reviewed so many questions on Stack Overflow but none still works in my case. I am using Laravel 5.4 and Xampp.

起初我以为是我的 Xampp 无法发送电子邮件,但当我进入实时模式(将其托管在共享主机上)时仍然存在同样的问题

At first I thought it was my Xampp that cannot allow sending the emails but also when I move to the live mode(hosted it on a shared hosting) still have same issues there as well

但是每当我将配置设置为使用 Mailtrap 时,它就可以工作,而且我知道 mailtap 只是一个开发邮件服务器,但是每当我使用 Gmail 时,它都会给我错误,例如 "Expected response code 220 but got code"", 带有消息 """

But whenever I set the configuration to use Mailtrap, it's working and I know mailtap is just a development mail server, but whenever I use the Gmail it give me error such as "Expected response code 220 but got code "", with message """

此外,当我在实时模式下尝试时,它仍然会出现同样的错误.

Also when I try it on live mode it still gives same error.

我的配置文件有以下内容

My configuration file has the following

.env

MAIL_DRIVER=smtp
MAIL_HOST=gmail-smtp-msa.l.google.com (also tried smtp.gmail.com)
MAIL_PORT=587
MAIL_USERNAME=email@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl

邮件.php

<?php

return [


    'driver' => env('MAIL_DRIVER', 'smtp'),

    'host' => env('MAIL_HOST', 'gmail-smtp-msa.l.google.com'),


    'port' => env('MAIL_PORT', 587),

    'from' => [
        'address' => 'email@gmail.com',
        'name' => 'Name Here',
    ],

    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

     'username' => env('MAIL_USERNAME', 'email@gmail.com'),

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



    'sendmail' => '/usr/sbin/sendmail -bs',
    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

];

推荐答案

除了Laravel端的配置,还需要在您的 Gmail 帐户中启用不太安全的应用".

As well as the configuration on the Laravel side, you need to enable "Less secure apps" in your Gmail account.

在 Laravel 方面,本指南显示了您的设置需要.使用 smtp.gmail.com 作为主机,使用 465/ssl587/tls.

On the Laravel side, this guide shows the settings you need. Use smtp.gmail.com for host, and either 465/ssl or 587/tls.

这篇关于Laravel Gmail 配置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)