使用Laravel Jetstream在用户名上无法在SMTP服务器上进行身份验证

发布于 2025-02-11 03:10:47 字数 1256 浏览 3 评论 0原文

我正在学习如何在用户使用Laravel 8更改系统角色时向用户发送电子邮件,并且我遇到了这个问题,我遵循的大多数教程都需要Google帐户打开较不安全的应用程序,但我无法更改设置在Google帐户中,它说此设置不再可用。我正在使用Laravel和Jetstream。以下是我遇到的错误:

Failed to authenticate on SMTP server with username "[email protected]" 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==".".`

有人知道如何在Laravel发送电子邮件或有关此操作的教程吗?谢谢。

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. I am using Laravel and Jetstream. Below is the error I'm getting:

Failed to authenticate on SMTP server with username "[email protected]" 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? Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿与i 2025-02-18 03:10:47

关注 this> this 生成新应用程序密码并设置您的 env 这样的文件,

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=YOUR_GENERATED_PASSWORD 
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

请确保您的 port 加密设置也已更改
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,
    ],

您可能需要清除缓存,然后再进行测试

php artisan config:cache

Follow this to generate new apps password and set your env file like this

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=YOUR_GENERATED_PASSWORD 
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

make sure your port and encryption setting is also changed in
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文