预期的响应代码235但是使用office365 smtp获得代码535 laravel发送电子邮件

问题描述 投票:0回答:1

我想在laravel应用程序中使用office365 smtp凭据发送电子邮件。我在.env文件中对电子邮件设置进行了更改,如下所示:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=info@***.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=tls

虽然我想发送电子邮件,但我得到了错误

Failed to authenticate on SMTP server with username \"[email protected]\" using 2 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 235 but got code \"535\", with message \"535 Incorrect authentication data\r\n\"

我的电子邮件发送代码如下

Mail::send(array(), array(), function ($m) use ($templatecontent) {
        $m->from('customerservice@****.com', 'TEST');
        $m->to('[email protected]', 'Test')
                ->subject($templatecontent['subject'])
                ->setBody($templatecontent['content'], 'text/html');
    });

任何人都可以指导我是什么问题以及如何解决这个问题?

laravel email office365 sendmail
1个回答
1
投票

我不知道原因是否与OP相同,但我得到了同样的错误。我通过用双引号括起密码来修复它。

我假设密码包含特殊字符时解析失败。

© www.soinside.com 2019 - 2024. All rights reserved.