-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Category
- Question
- Typo
- Bug
- Additional article idea
Expected or Desired Behavior
We are using the method
Microsoft.SharePoint.Client.Utilities.Utility.SendEmail(ClientContext, EmailProperties)
to send mails from a backend web API hosted in Azure App Service to Office 365 users.
We are expecting to get all of those mails delivered to the recipient.
Observed Behavior
This works about 90% of the time. Sometimes it fails.
When it fails:
The subsequent call to ClientContext.ExecuteQuery() fails with an error stating that the IP of the sender has been banned:
Microsoft.SharePoint.Client.ServerException: Mailbox unavailable. The server response was: 5.7.606 Access denied, banned sending IP [52.105.0.167]. To request removal from this list please visit https://sender.office.com/ and follow the directions. For more information please go to http://go.microsoft.com/fwlink/?LinkID=526655 (AS16012609) [DB5EUR03FT022.eop-EUR03.prod.protection.outlook.com]
As this is happening on the Microsoft side, the banned IP is obviously not our server. It is one of Microsofts own mail servers. The IP address varies but the one mentioned above is the one that we mostly see in the error message. I also tried to delist it using the link from the error but that didn't help.
As I've said the mail is being sent by Microsoft's own servers. Interestingly some of those seem to be blacklisted at other Microsoft servers. We implemented a retry mechanism that seems to solve it because on the second or third try the mail will get sent by another server which is OK.
Also important to know:
- All mails are sent to internal recipients known to the site (they are in the hidden user list) to which the ClientContext is connected.
- The executed code is always the same and so are the recipients. The same mail sent to the same recipient sometimes just fails.
- About 30 of those mails get sent per day - so it is not a matter of a massive number of mails. And they are not all sent at the same time. Sometimes 2 or 3 get sent at the same time.
Steps to Reproduce
Sadly it is hard to reproduce. In other words it's not like "do this" and then it fails. You'll have to send a bunch of mails throughout the day to see it happen.
Question
Is there anything we could do to avoid the blacklisted servers? This is still a test system and I'm afraid of using that in production as those mails are important and there's no guarantee that we won't get 3 times in a row on a blacklisted server.