[英]Laravel, Failed to authenticate on SMTP server with username "" using 3 possible authenticators
I am trying to find out why this happens.我试图找出为什么会发生这种情况。
.env .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=*******t@gmail.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
mail.php邮件.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '******@gmail.com', 'name' => 'Project'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('******@gmail.com'),
'password' => env('******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
];
This is the error这是错误
Failed to authenticate on SMTP server with username "" using 3 possible authenticators. Authenticator LOGIN returned Swift_TransportExce ▶
534-5.7.14 GVHg3-rU8SDpVLdwnIPviBCjKNnBRcxuU2N3-pcUWd0TeMbM_vULrHhQcVNXjhoewjrquW\r\n
534-5.7.14 Jttd6jNXfnledZiAMv-rjMvpnd01nas-2J2BYU_Krd4kzT-YmTR_HW9uW3S6Ts2jUxDaC8\r\n
534-5.7.14 XmT_TV9QqYXHXkTMcrX3OG9D4QyF4E6w7fwnu2bYZT36rZXTU-HqJwlWzJBv8-MC2P9xrN\r\n
534-5.7.14 cUd4-BirG0rfAjlDxy5bkbon3S_bIFSZQVd0-5wskctUR4do7F> Please log in via\r\n
534-5.7.14 your web browser and then try again.\r\n
534-5.7.14 Learn more at\r\n
534 5.7.14 https://support.google.com/mail/answer/78754 l5-v6sm1366079wrv.84 - gsmtp\r\n
" in C:\xampp\htdocs\wer\walrer\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php:457\n
Stack trace:\n
I checked email credentials and they are the same.我检查了电子邮件凭据,它们是相同的。 In this project I have used authentication , but can't find a solution to this one.在这个项目中,我使用了 authentication ,但找不到解决方案。
I think there is something wrong with your mail.php
file.我认为您的mail.php
文件有问题。
You should be passing the variable names to the env()
function for username
and password
.您应该将变量名称传递给username
和password
的env()
函数。
So this:所以这:
'username' => env('******@gmail.com'),
'password' => env('******'),
Becomes this:变成这样:
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
Your .env
file looks good.您的.env
文件看起来不错。
You mail.php
file should look like this:您的mail.php
文件应如下所示:
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => '******@gmail.com', 'name' => 'Project'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', '******@gmail.com'),
'password' => env('MAIL_PASSWORD', '******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
];
The value in the second parameter for the env()
function, gets used if the .env
key specified in the first parameter is not found.如果未找到第一个参数中指定的.env
键,则使用env()
函数的第二个参数中的值。
您需要在您的谷歌帐户中启用安全性较低的应用程序访问才能使其正常工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.