[英]Failed to authenticate on SMTP server with username using Laravel Jetstream
I'm learning how to send email to the user whenever their system role change using Laravel 8 and I had this issue where most tutorials that I'm following requires the Google Account to turn on the Less Secure Apps, but I cannot change the settings in the Google Account anymore it says This setting is no longer available
.我正在学习如何在使用 Laravel 8 更改系统角色时向用户发送电子邮件,并且我遇到了这个问题,我正在遵循的大多数教程都需要 Google 帐户打开不太安全的应用程序,但我无法更改设置在 Google 帐户中不再显示This setting is no longer available
。 I am using Laravel and Jetstream.我正在使用 Laravel 和 Jetstream。 Below is the error I'm getting:以下是我得到的错误:
Failed to authenticate on SMTP server with username "myEmail@gmail.com" using the
following authenticators: "LOGIN", "PLAIN", "XOAUTH2". Authenticator "LOGIN" returned
"Expected response code "235" but got code "535", with message "535-5.7.8 Username and
Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?
p=BadCredentials j2-20020a654282000000b003fe28130b12sm5399227pgp.62 - gsmtp".". Authenticator
"PLAIN" returned "Expected response code "235" but got code "535", with message "535-5.7.8
Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?
p=BadCredentials j2-20020a654282000000b003fe28130b12sm5399227pgp.62 - gsmtp".". Authenticator
"XOAUTH2" returned "Expected response code "235" but got code "334", with message "334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==".".`
Does anyone know how to send emails in laravel or a tutorial on doing it?有谁知道如何在 laravel 中发送电子邮件或有关如何发送电子邮件的教程? Thank you.谢谢你。
Follow this to generate new apps password and set your env file like this按照此生成新的应用程序密码并像这样设置您的env文件
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=YOUR_GMAIL@gmail.com
MAIL_PASSWORD=YOUR_GENERATED_PASSWORD
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
make sure your port and encryption setting is also changed in mail.php确保您的端口和加密设置也在mail.php中更改
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
],
you probably need to clear cache before test it out您可能需要在测试之前清除缓存
php artisan config:cache
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.