Samir Mammadhasanov
Samir Mammadhasanov

Reputation: 875

Can't connect Office365 to Laravel mail

I connected Office365 account to laravel smtp mailer. But when I want to send mail I get exception:

Expected response code 250 but got code "550", with message "550 5.7.708 Service unavailable. Access denied, traffic not accepted from this IP. For more information please go to http://go.microsoft.com/fwlink/?LinkId=526653 AS(8561)

I also added my server IP to Admin->Protected->Connection filter->Allowed IP list.

My .env:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=25
MAIL_USERNAME=username
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=username
MAIL_FROM_NAME=MyOffice

Upvotes: 0

Views: 2500

Answers (2)

brokedid
brokedid

Reputation: 899

you can also use this Mail-Driver: https://github.com/motze92/office365-mail

With SMTP and office365 we had many timeout problems and temporarely errors. Sending mails over graph rest api works better.

Upvotes: 0

Marc LaFleur
Marc LaFleur

Reputation: 33094

From the link in your question:

5.7.700-749 : Access denied, tenant has exceeded threshold

The majority of traffic from this tenant has been detected as suspicious and has resulted in a ban on sending ability for the tenant.

Ensure that any compromises or open relays have been resolved, and then contact support through your regular channel.

Your tenant/subscription has been flagged for suspicious SMTP traffic. You need to contact Microsoft Support directly to correct the issue and remove the SMTP block.

Upvotes: 2

Related Questions