dpakagarwal's avatar

Error while sending mail using office365 smtp details

I have created a custom authentication system using Otp and mailing. and I am using office365 SMTP details to send a mail to user who is just registering in or logging in. but while registering it takes too load and gives me an error as displayed below:

Swift_TransportException
Failed to authenticate on SMTP server with username "{email_id}" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Mailbox. Visit https://aka.ms/smtp_auth_disabled for more information. [BMXPR01CA0027.INDPRD01.PROD.OUTLOOK.COM] ". Authenticator XOAUTH2 returned Expected response code 235 but got code "535", with message "535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Mailbox. Visit https://aka.ms/smtp_auth_disabled for more information. [BMXPR01CA0027.INDPRD01.PROD.OUTLOOK.COM] ".

and my office365 SMTPdetails are shown below:

MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME={email_id}
MAIL_PASSWORD={app_password}
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS={email_id}
MAIL_FROM_NAME="${APP_NAME}"

is there any other method to send using office365 SMTPdetails in laravel 8

0 likes
31 replies
dpakagarwal's avatar

@Sinnbeck I have done whatever steps are done in the link but didn't effect anything, and gives me same error

Sinnbeck's avatar

@deepakagarwal so if you check the user on the page it has a check in Authenticated SMTP? Remember to refresh the page before checking

Verify the Authenticated SMTP setting: unchecked = disabled, checked = enabled.

Sinnbeck's avatar

@deepakagarwal go to admin.microsoft.com as an admin user. Users->Active users->Click the user->Mail (tab)->Manage email apps

There you need to make sure that "Authenticated SMTP" is checked

1 like
dpakagarwal's avatar

@Sinnbeck as you said above for ensuring, it is checked and after that i have tried it but same error is going on while registering

dpakagarwal's avatar

I want to ask the question as it takes 3 to 4 mins in loading and after that it says error, it should require queue process in mailable in laravel 8

dpakagarwal's avatar

@Sinnbeck whole project should i share with you or only paticular controller with mailable file

Sinnbeck's avatar

@deepakagarwal I dont think this is a code problem, if you are getting this error still SmtpClientAuthentication is disabled for the Mailbox. If the portal says that it is enabled, you could try contacting your Microsoft reseller, to have them check if some other permission is wrong, or create a support ticket with microsoft themselves.

dpakagarwal's avatar

@Sinnbeck what you have said , i already did it but again same bullshit error is occuring . is there another way to resolve it

dpakagarwal's avatar

@Sinnbeck is my client-based project and he is using the office365 mail provider for sending and receiving mails. so what would be the next solution for this

dpakagarwal's avatar

@PaulMaxOS as you said above I had added smtp-legacy.office365.com in mail_HOST but it also gives me only above mentioned error

Sinnbeck's avatar

@deepakagarwal And microsoft says that the error is due to an error in your set up and not a misconfiguration in their end? The error implies that the error is at Microsoft, not in your code.

PaulMaxOS's avatar

@Sinnbeck As far as I understood the docs, they're deprecating auth using legacy TLS. This might be the reason why he is not able to authenticate using his current TLS setup although everything's looking fine on his and on Microsofts end. That's why I suggested him to have a look at the auth using legacy TLS: He might be simply using the wrong endpoint.

PaulMaxOS's avatar

@deepakagarwal ok... and you also did this?

To use this less secure endpoint, admins need to enable the following setting:

The value $true for the AllowLegacyTLSClients parameter on the Set-TransportConfig cmdlet.
dpakagarwal's avatar

@Sinnbeck I don't know from where the error is occurring, if you want any type of file I can share with you which files to see and check if any error from my side then help me out to resolve it as its making me complicating right now

Sinnbeck's avatar

@deepakagarwal My config is 100% the same as this on a new installation of laravel, and it works

MAIL_MAILER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected] <-check if these work at https://outlook.com
MAIL_PASSWORD=passwordForMail <-check if these work at https://outlook.com
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"
dpakagarwal's avatar
dpakagarwal
OP
Best Answer
Level 1

@Sinnbeck I have reset all configuration in AAD FROM START POINT AND ITS WORK NOW.

raphael's avatar

I had to use MAIL_HOST=smtp-legacy.office365.com

Please or to participate in this conversation.