Expected response code 235 but got code 535 laravel send email using office365 smtp

泄露秘密 提交于 2020-05-13 07:36:33

问题


I want to send email using my office365 smtp credentials in laravel application. i have make changes in my .env file for email settings as below:

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

while i am trying to send email i got error like

Failed to authenticate on SMTP server with username \"info@omoyyc.com\" 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\"

my email sending code is as below

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

Can anyone guide me what is the issue and how to solve this issue?


回答1:


I don't know if the cause is the same as OP, but I got the same error. I fixed it by enclosing the password with double quotes.

I'm assuming that the parsing fails when the password contains special characters.




回答2:


my problem is same dude, but my problem has been solved to try it :

  1. Go to https://myaccount.google.com/security#connectedapps
  2. Take a look at Security menu -> Apps with account access menu.
  3. You must turn the option "Allow less secure apps" ON.

If you already followed this step, try again your project. and if it still doesn't work, please continue this steps :

  1. Visit https://accounts.google.com/UnlockCaptcha
  2. Click continue button

Good Luck dude!



来源:https://stackoverflow.com/questions/53298872/expected-response-code-235-but-got-code-535-laravel-send-email-using-office365-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!