Sp-dev-docs: CSOM SendEmail unreliable

Created on 20 Nov 2019  路  12Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [x] 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.

other question

All 12 comments

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

Same issue here,
Using the method SendMail

var emailp = new EmailProperties();
emailp.To = to;
emailp.From = "";
emailp.Body = body;
emailp.Subject = subject;
Utility.SendEmail(ctx, emailp);
ctx.ExecuteQueryRetry();

We are getting the following exception:

Mailbox unavailable. The server response was: 5.7.606 Access denied, banned sending IP [xxx.xxx.xxx.xxx]. 
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) [VE1EUR03FT006.eop-EUR03.prod.protection.outlook.com] 

This has been happening for a while and delisting the IPs seems not to work at all....

The same issue happens here too, with an extra flavor: a random _Unable to send to all recipients_ exception, even if is only a maximum of 5 email recipients and all of them have active and working internal accounts.

Same issue here but I'm using SharePoint REST API. Our custom solution sends two emails in sequence and the first one usually works but the second gets this Access denied error. This seems to have started a week or two ago? Before that, we never had any issues (even though we don't use this solution every day).

I don't think this is a problem in CSOM, but in the internal operations of SharePoint and Exchange Online where Microsoft basically has blacklisted themselves.

I also have the same issue, through REST - SP.Utilities.Utility.SendEmail.
I've tried removing the listing but when I next time got another IP in the error message I realized it would be a never ending job.

{
"readyState":4,
"responseText":"{
\"error\":{
\"code\":\"-1,
System.Net.Mail.SmtpFailedRecipientException\",
\"message\":{
\"lang\":\"sv-SE\",
\"value\":\"Mailbox unavailable. The server response was: 5.7.606 Access denied, banned sending IP [104.146.225.177]. 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) [AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com]\"
}
}
}",
"responseJSON":{
"error":{
"code":"-1,
System.Net.Mail.SmtpFailedRecipientException",
"message":{
"lang":"sv-SE",
"value":"Mailbox unavailable. The server response was: 5.7.606 Access denied, banned sending IP [104.146.225.177]. 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) [AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com]"
}
}
},
"status":500,
"statusText":"error"
}

The same here:

Error sending e-mailMicrosoft.SharePoint.Client.ServerException:
Mailbox unavailable. The server response was: 5.7.606 Access denied, banned sending IP [52.105.xxx.xxx]. 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) [DB5EUR03FT052.eop-EUR03.prod.protection.outlook.com]
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at ...

I wonder if it's related to: https://admin.microsoft.com/AdminPortal/Home#/MessageCenter?id=MC192693

Best regards
Tobias

Experiencing the same issues here.

OK, seems that Microsoft is completely ignoring this issue. If anyone has access to premier support it would be great if he could open a ticket there to force them into a reaction.

Hey @cwdata

I have used our premier support and this is the word from microsoft.

Short-term solution:
Access https://sender.office.com/ and follow the steps to delist the blocked IP your get from the error message. Customer may get different IPs when encounter this issue, so we need to delist each of them from black list. If you cannot get the IP address, contact us with error message and timestamp to check it from backend log.

Long-term solution:
The Exchange Online Product Group has backlogged work items to address this issue, but there is no ETA for now.

Thanks @NotAlexx
at least we now know, that Microsoft is tracking this issue.
As we and others have made the experience that delisting the blocked IPs does not help this will be a waste of time. So we will have to wait.
Looking at our logs most of the times one retry is enough to get the mail sent. We rarely need 2 retries.

No worries, in the meantime I am doing an http request to a flow and sending emails from there.

Cheers

Folks, I'm removing the "needs MS review" tag here as a team in Microsoft (Exchange) is already aware of the issue and has a workitem assigned to solve it (as mentioned before). Happy to leave this open here and close it once the fix has been reported to be deployed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

byrongits picture byrongits  路  3Comments

zerovectorspace picture zerovectorspace  路  3Comments

thechriskent picture thechriskent  路  3Comments

jonthenerd picture jonthenerd  路  3Comments

mikeparkie picture mikeparkie  路  3Comments