无法使用 smtp.office365.com 中的用户名在 SMTP 服务器上进行身份验证 [英] Failed to authenticate on SMTP server with username in smtp.office365.com

查看:204
本文介绍了无法使用 smtp.office365.com 中的用户名在 SMTP 服务器上进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Laravel-5.8 项目中,我尝试使用 office365 发送电子邮件/通知

In my Laravel-5.8 project I am trying to send email/notification using office365

config/mail.php

config/mail.php

<?php

  return [

    'driver' => env('MAIL_DRIVER', 'smtp'),

    'host' => env('MAIL_HOST', 'smtp.office365.com'),

    'port' => env('MAIL_PORT', 587),

    'from' => [

        'address' => env('MAIL_FROM_ADDRESS', 'testingemail@mycompany.com'),
        'name' => env('MAIL_FROM_NAME', 'JJJ'),
    ],


    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    'username' => env('MAIL_USERNAME','testing@mycompany.com'),

    'password' => env('MAIL_PASSWORD','testing'),


    'sendmail' => '/usr/sbin/sendmail -bs',

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],

    'log_channel' => env('MAIL_LOG_CHANNEL'),

];

但是我收到了这个错误:

But I got this error:

#message: """;无法使用用户名testing@mycompany.com"在 SMTP 服务器上进行身份验证;使用 2 个可能的身份验证器.身份验证器登录返回预期响应代码 235,但得到代码535",消息为535 5.7.3 身份验证失败 [LO2P265CA0268.GBRP265.PROD.OUTLOOK.COM] ◀".身份验证器 XOAUTH2 返回预期响应代码 235,但得到代码535",消息为535 5.7.3 身份验证失败 [LO2P265CA0268.GBRP265.PROD.OUTLOOK.COM] ◀"."""

#message: """ Failed to authenticate on SMTP server with username "testing@mycompany.com" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful [LO2P265CA0268.GBRP265.PROD.OUTLOOK.COM] ◀ ". Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.3 Authentication unsuccessful [LO2P265CA0268.GBRP265.PROD.OUTLOOK.COM] ◀ ". """

我该如何解决?

谢谢

推荐答案

请将此代码写在env文件中

使用您的 smtp 邮件而不是 smtp.office365.com

MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=testing@mycompany.com
MAIL_PASSWORD=testing
MAIL_ENCRYPTION=tls

然后运行命令

php artisan config:cache

这篇关于无法使用 smtp.office365.com 中的用户名在 SMTP 服务器上进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆