沃梦达 / 编程问答 / php问题 / 正文

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 配置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Laravel Gmail 配置错误

基础教程推荐