motze92 / office365-mail

Office365 transport for Laravel
MIT License
62 stars 21 forks source link

Rate limiting / throttling #32

Open beard7 opened 1 year ago

beard7 commented 1 year ago

Is there a way to implement rate limiting / throttling on the number of mails sent per second? The Symphony AbstractTransport class has a setMaxPerSecond method which sets a rate public property, but I don't think that would have any impact here.

I'm running into a problem where emails are failing with: 503 Service Unavailable response: {"error": {"code":"ResourceUnhealthy","message":"MdbReplicationProtectionUtilizationMonitor is unhealthy."} }

I've contacted Microsoft support and they tell me this is due to sending too many requests, essentially the same as a 429 error.

Microsoft provides some info on how to handle this here: Best Practices essentially using the Retry-After header, but I don't know if this is something that can be implemented with this mail driver.

Any advice is much appreciated.

motze92 commented 1 year ago

Maybe you can prevent this by using schedules?

beard7 commented 1 year ago

Thanks. I'd forgotten about this issue. It's easily solved by using Laravel's built in queue throttling options.