SharePoint 2013 – “An unexpected error has occurred” when configuring incoming E-Mail settings
While trying to enable incoming E-mail settings for a document library within SharePoint 2013 I received the following error:
An unexpected error has occurred.
I used the Merge-SPLogFile PowerShell cmdlet to collate all log entries relating to the correlation ID. The resulting log file didn’t contain anything helpful other than this:
Application error when access /_layouts/15/EmailSettings.aspx, Error=An existing connection was forcibly closed by the remote host Getting Error Message for Exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte buffer, Int32 offset, Int32 size)
In an attempt to determine which remote server was closing the connection I enabled verbose logging using the Set-SPLogLevel PowerShell cmdlet and reproduced the error:
Set-SPLogLevel -TraceSeverity VerboseEx
Frustratingly, the log file still did not contain any hints as to which server was closing the connection. After hours of trawling through Google results for the above error I resorted to installing Microsoft Network Monitor on the WFEs to run a network trace while reproducing the error. I could not see any traffic to a domain controller, so assumed it wasn’t failing at the point of creating the object in Active Directory. I could only see traffic between SharePoint WFEs and Application servers.
So, to cut a very long story short the solution was quite simple – SharePoint no longer likes the self-signed certificate that was installed on the Central Administration web site, which is strange as this previously worked. After generating a new certificate for Central Administration via our internal root CA the problem has gone away, I can now enable incoming-email and files attached to test emails arrive in the document library. I can only assume that somewhere along the line an update has changed the policy.