无法使用 3 个可能的身份验证器在用户名 \"yourmail@gmail.com" 的 SMTP 服务器上进行身份验证 身份验证器返回登录 预期的存储库



你们能帮我解决这个问题吗!我想通过电子邮件通知作为服务确认。该电子邮件通过本地主机电子邮件谷歌工作。这很好用。但是,当我在服务器(Centos服务器(上托管时,它不起作用。我已经设置了";关于";";不太安全的应用程序访问";而且

请帮助

.env文件

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=yourmail@gmail.com
MAIL_FROM_NAME="Test System"
MAIL_PASSWORD=yourpassword@123
MAIL_ENCRYPTION=tls

config/mail.php

<?php

退货

/*
|--------------------------------------------------------------------------
| Default Mailer
|--------------------------------------------------------------------------
|
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
|            "postmark", "log", "array"
|
*/
'mailers' => [
'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,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],
'mailgun' => [
'transport' => 'mailgun',
],
'postmark' => [
'transport' => 'postmark',
],
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],

];

服务器中的错误弹出窗口

无法在SMTP服务器上使用用户名"进行身份验证;yourmail@gmail.com"使用3个可能的验证器。验证器LOGIN返回预期响应代码235,但得到代码";534〃;,带有消息";534-5.7.14<https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbv\r\n534-5.7.14 6QwiGpAN3JU8gappy5A_Cl9KLH2CIjz98b5ufHVlyZK-VAesyRaqeQrx5RLudEYe6S9zR\r\n534-5.7/14 j5MPM-5qY6oL3dc6fcv5omIkkEus6rK_Wz8pAYdVSQo6to3FEea26ujWqiO5L>\\r\n534-5.7.14请通过web浏览器登录,然后重试。\\r\n534-5.7.14有关详细信息,请访问\r\n534 5.7.14https://support.google.com/mail/answer/78754h13-20020a056a00230d00b004f427ffd485sm16382266pfh.143-gsmtp\r\n"。验证器PLAIN返回预期响应代码235,但得到代码";534〃;,带有消息";534-5.7.14<https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbs\r\n534-5.7.14 M7gUR-WFJS5p6fdwdulgY_ECc3U6v49WszVBavDfpGRm_qGZD-pRnZqVELJel_QbhfC6\r\n534-5.7.114 tfFapza74BulVzQiOQBRNVudGg-XdjDE-WVQB0xDmiXh0pJ1lFYIlN3braZrpj87>\\r\n534-5.7.14请通过web浏览器登录,然后重试。\\r\n534-5.7.14有关详细信息,请访问\r\n534 5.7.14https://support.google.com/mail/answer/78754h13-20020a056a00230d00b004f427ffd485sm16382266pfh.143-gsmtp\r\n"。验证器XOAUTH2返回预期响应代码250;535〃;,带有消息";535-5.7.8不接受用户名和密码。有关详细信息,请访问\r\n535 5.7.8https://support.google.com/mail/?p=BadCredentialsh13-20020a056a00230d00b004f427ffd485sm16382266pfh.143-gsmtp\r\n"。

Gmail

在响应中,您可以看到...Please log in via your web browser and then try again...。这表示您进入了OAuth流。在localhost场景中,它可能起作用,因为您之前已经批准了Gmail OAuth对话框。您必须在谷歌控制台中注册/授权您的应用程序。

看看这里:https://developers.google.com/gmail/api/auth/about-auth

如果有人在2023年遇到问题。试试这个方法。谷歌改变了安全政策。现在"允许不太安全的应用程序">选项在"登录&安全
这就是为什么您必须先(管理您的谷歌帐户(,然后搜索[应用程序密码]并选择应用程序密码选项。

->然后,您会看到一个输入框,您必须在其中输入应用程序名称才能创建密码。

->您将从Swift_TransportException错误消息中找到您的应用程序名称。它是这样的(535-5.7.8(

->查看此图像以更好地理解。

在此处输入图像描述

->然后使用此应用程序名称创建密码。->然后您将从Google获得一个密码,并将此密码放入.env文件MAIL_password选项中。希望它能起作用。

相关内容

最新更新