Reputation: 1323
In my Laravel-5.8 project I am trying to send email/notification using office365
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', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'JJJ'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME','[email protected]'),
'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: """ Failed to authenticate on SMTP server with username "[email protected]" 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] ◀ ". """
How do I resolve it?
Thanks
Upvotes: 3
Views: 20998
Reputation: 21
In your .env file, use SendMail instead of smtp
ex:
MAIL_DRIVER=SendMail
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=testing
MAIL_ENCRYPTION=tls
Upvotes: 0
Reputation: 482
I had the same issue, tried all the suggestions on google before finally having to call Microsoft Support. The operator got me to change some security properties in the Microsoft Azure Active Directory at portal.azure.com
And here's my .env variables:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=xxxxxx
MAIL_PASSWORD=xxxxx
MAIL_ENCRYPTION=tls
Please see the screenshot for instructions.
Upvotes: 3
Reputation: 6005
please write this code in env file
use your smtp mail instead of smtp.office365.com
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=testing
MAIL_ENCRYPTION=tls
then run command
php artisan config:cache
Upvotes: 1