Share via


Outgoing Email issue with SharePoint 2016

Issue:

In our SharePoint 2016 farm, where outgoing emails not working from couple of servers. It include Alerts email, Sharing email, workflow email etc. 
One of the Web front (KFSP1) in SharePoint 2016 Server is unable to send the email using the exchange relay. 

Troubleshooting:

We checked following settings.

  • Outgoing email settings properly configured.
  • Server is properly registered with Exchange Relay
  • Checked the CSP(Software firewall), No SMTP port (25) blocked by CSP.
  • No Antivirus blocking
  • No Firewall blocking.
  • When we checked the ULS logs and found these entries.

Time: 05/18/2018 10:52:26.19

Attempting to send mail to recipients: test@krossfarm.com. Mail Subject: You have successfully created an alert for 'Documents-10182017-1'. Stack Trace:  

 at Microsoft.SharePoint.Email.SPSmtpClient.SendOnce(MailMessage msg, Boolean useAlternateServer)   

 at Microsoft.SharePoint.Email.SPSmtpClient.Send(MailMessage msg)   

 at Microsoft.SharePoint.Email.SPSmtpClient.TrySend(MailMessage msg)   

 at Microsoft.SharePoint.Email.SPMailMessageHelper.TrySendMailMessage(SPSmtpClient smtpClient, MailMessage mailMessage, SPUserToken currentUserToken, Nullable`1 currentUserInfo, Boolean useEwsIfFromCurrentUser, Boolean doNotSaveCopy)   

 at Microsoft.SharePoint.SPManagedCodeInterop.SendEmail(Guid webApplicationId, SPSite site, String from, String replyTo, String sender, String[]& to, String[]& cc, String[]& bcc, Object& headers, String subject, String body, Boolean isBodyHtml, Int32 bodyCodePage, String

 

 

Failed attempt 1 sending mail to recipients: test@krossfarm.com. Mail Subject: You have successfully created an alert for 'Documents-10182017-1'. Error: SmtpException while sending email: System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was: Server configuration rejects your message from that IP address    

 at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)   

 at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)   

 at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)   

 at System.Net.Mail.SmtpClient.Send(MailMessage message)   

 at Microsoft.SharePoint.Email.SPSmtpClient.SendOnce(MailMessage msg, Boolean useAlternateServer)   

 at Microsoft.SharePoint.Email.SPSmtpClient.Send(MailMessage msg)

 

SPSmtpClient Failure: Failed attempt 3 sending mail to recipients: test@krossfarm.com. Mail Subject: You have successfully created an alert for 'Documents-10182017-1'. Error: SmtpException while sending email: System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was: Server configuration rejects your message from that IP address    

 at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)   

 

SPSMTPClient.TrySend::Exception caught; return value from TrySend will be false.  Exception: System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was: Server configuration rejects your message from that IP address    

 at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)   

 

Failed to send an email using SMTP.

 

These entries clearly telling us, SharePoint is trying to send the email using the exchange (SMTP) but exchange is rejecting the message which is coming from our server's IP.  "The server response was: Server configuration rejects your message from that IP address".

  • We also try to send the email using the command line, we tried on both Working and Non working server. On KFSP1( faulty server)

  • When we try to send the email on working server's and this is what we get:

  • And I see the email in my mail box:

Now we approach the Exchange team and asked them about the why exchange is rejecting SharePoint request. Exchange team give us the IP address which is being used to send the message. They told us that IP is not registered with exchange relay. Ah, when we checked, that IP belongs to web application rather than base server IP.

Cause:

In SharePoint 2016, we change our policy and having the dedicated IP for each web application. Now every web front end has 4 (1 for server and 3 for web applications) IP address bind with Network Interface Card (NIC). All the IPs are properly bind with NIC and configured in IIS.  Same settings, we applied to all WFE but don’t know why only one wfe having the issue and using wrong IP to send the email.

With exchange, we can only ask Server's IP (Source IP) for the exchange relay registration.

Actually, problem is with IP address itself. In Windows server 2008 and above, there is policy change from MSFT which is, source IP address on a NIC will always be the lowest numerical IP in the list (bind NIC) instead of the first IP bind to NIC for server communication. That's it.

When we checked further and found that the our server's base IP (19.168.0.26) is not the lowest in the numerical value, So SharePoint use the Lowest IP to send the email which is in our case Team web app (19.168.0.21).

List of Ips on the Server:

Servers Base IP

19.168.0.26

Team

19.168.0.21

MySite

19.168.0.22

 

Resolution:

In order to Resolve this issue, we have to re-register our IPs with Servers. This means, we have to remove all the Ips from the server and re-add them using the command line tool Netsh.

  • First we have to remove all the IPS from the NIC using GUI.
  • Now open the PowerShell windows and register the Ips.
  • Server's base IP should be 1st one in the registration.
  • Netsh Interface IPv4 Add Address "NICTeam1" 19.168.0.26
    • Where NicTeam1 is the name of the NIC card on the server.
    • Now register all remaining IPS like this. (Make Sure User the SkipAsSource= true paramater otherwise we will see the same issue.

Netsh Interface IPv4 Add Address "NICTeam1" 19.168.0.21 255.255.255.0 SkipAsSource=True

Netsh Interface IPv4 Add Address "NICTeam1" 19.168.0.22 255.255.255.0 SkipAsSource=True

Netsh Interface IPv4 Add Address "NICTeam1" 19.168.0.23 255.255.255.0 SkipAsSource=True

  • Once completed, we can test it if all the Ip registered properly. Run the following command for verification.
  • netsh int ipv4 show ipaddresses level=verbose
  • In the Output, Please Make Sure Server's base IP's SkipAsSource Status = False and all others are true.

See Also:

This article gives us the direction and later we confirmed with MSFT support which they confirmed it.