Our application needs to get email subject, sender, recipients etc from Gmail Sent folder. It was working fine for several months, however it starts acting up out of sudden. We are using AE.Net.Mail to create ImapClient
new ImapClient("imap.gmail.com", "n/a", () => GmailSaslRequestBuilder.Build(email, this._authenticator.GetAccessToken()), ImapClient.AuthMethods.XOAUTH2, 993, true);
Here is the error message I got, I was wondering if we got throttled and how to work around the issue or what else could be the issue?
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<newline>
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)<newline>
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)<newline> --- End of inner exception stack trace ---<newline>
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)<newline>
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)<newline>
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)<newline>
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)<newline>
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)<newline>
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)<newline>
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)<newline>
at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)<newline>
at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost)<newline>
at AE.Net.Mail.TextClient.Connect(String hostname, Int32 port, Boolean ssl)<newline>
at AE.Net.Mail.ImapClient..ctor(String host, String username, Func`1 getPassword, AuthMethods method, Int32 port, Boolean secure)<newline>
Since I do not have 50 point thingies I cannot comment on your question, so instead I will write my comment in an answer form and you can comment bellow.
Anyways, the start of your error "System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host" usually is caused by the MX settings on your server. I would start by checking your MX record verification.
But if this is not the issue, comment below and I can then comment.