laravel 邮件错误:-无法使用3个可能的身份验证器在SMTP服务器上使用用户名“www.example.com“进行身份验证support@myDomain.io

3phpmpom  于 2023-01-03  发布在  其他
关注(0)|答案(1)|浏览(356)

Google mail在发送邮件方面运行良好,但domain-mail(support.myDomain.io)返回以下错误
第一个月
环境代码:-

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=support@myDomain.io
MAIL_PASSWORD=******
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=support@myDomain.io
MAIL_FROM_NAME="${APP_NAME}"

控制器代码:-

Mail::to($data->email)->send(new EmailVerify($data));

邮箱/电子邮件验证. php

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class EmailVerify extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Email from '.env('APP_NAME'))->view('mail.emailVerify')->with(['data' => $this->data]);
    }
}

配置文件/邮件地址:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | 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'),
        ],
    ],

];

当我使用相同的代码谷歌邮件运行完美

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mymail.gmail.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=mymail.gmail.com
MAIL_FROM_NAME="${APP_NAME}"

我正在尝试从我在laravel的域名邮箱(support@myDomain.com)发送邮件。
我在谷歌上搜索了很多,但是没有找到一个合适的答案。如果你们能帮助我,我将非常高兴。

lrpiutwd

lrpiutwd1#

您是否打开了"允许不太安全的应用程序"?如果没有,请转到此链接
https://myaccount.google.com/security#connectedapps
查看登录和安全-〉应用程序与帐户访问菜单。
您必须打开"允许不太安全的应用程序"选项。
如果仍然不起作用,请尝试以下方法之一:
转到https://accounts.google.com/UnlockCaptcha,然后单击"继续"并解锁您的帐户,以便通过其他媒体/网站访问。
在. env中使用双引号输入密码:"您的密码"
另外,不要忘记清除缓存

php artisan config:clear

相关问题