繁体   English   中英

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

[英]Failed to authenticate on SMTP server with username using Laravel Jetstream

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

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==".".`

有谁知道如何在 laravel 中发送电子邮件或有关如何发送电子邮件的教程? 谢谢你。

按照生成新的应用程序密码并像这样设置您的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}"

确保您的端口加密设置也在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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM