Laravel Gmail Configuration Error(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/ssl
或 587/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 配置错误
基础教程推荐
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01