Spire.Email for .NET is a professional .NET Email library specially designed for developers to create, read and manipulate emails from any .NET (C#, VB.NET, ASP.NET) platform with fast and high quality performance.

Thu Oct 21, 2021 7:58 pm

Hi,

I'm working with Spire.Email.Pop3 to receive emails with C#.

The pop host is microsoft office365 as the following
pop.Host = "outlook.office365.com";

most of time i get the following error in pop.Connect(); as the following :

System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at spr?.?(Object A_0)
at spr?.?()
at spr?.Read(Byte[] buffer, Int32 offset, Int32 count)
at spr?.Read(Byte[] buffer, Int32 offset, Int32 count)
at spr?.?(spr? A_0, Boolean A_1, String A_2)
at spr?.?(spr? A_0)
at spr?.?(String A_0, Int32 A_1, Boolean A_2)
at spr?.?(String A_0, Int32 A_1, Boolean A_2)
at spr?.?(Boolean A_0)
at Spire.Email.Pop3.Pop3Client.Connect()


All the blogs are recommending to enable more security protocol.
I added the following line before pop.Connect(); but the issue not solved
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

mostafa340
 
Posts: 2
Joined: Thu Oct 21, 2021 7:14 pm

Fri Oct 22, 2021 5:40 am

Hello,

Thanks for your post.
I used our latest Spire.Email Pack(hot fix) Version:4.7.0 to test this case like the below screenshot. It could work well. Please firstly check if you did the correct settings. Meanwhile, if you were using an old version, I suggest that you upgrade to the latest one to try again. Look forward to your further testing result.
Pop3Client.png

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Fri Oct 22, 2021 12:39 pm

Hello Lisa,

Thanks for your reply, Your support is much appreciated.

I upgraded to 4.7 and here is the test result.
Sometimes the connection was successful and sometimes failed with the same error.
 
I created the following function and looped this function, 80% of the time it returned false with "System.IO.IOException: Authentication failed because the remote party has closed the transport stream."
and 20% of the time connected successfully and returns true and i can retrieve the inbox and delete messages.


        static bool IsPopConnected(Pop3Client pop1)
        {
            try
            {
                pop1.Host = "outlook.office365.com";
                pop1.Username = EmailAddress;
                pop1.Password = mailpassword;
                pop1.Port = 995;
                pop1.EnableSsl = true;
                pop1.Connect();
                return true;
            }
            catch
            {
                return false;
            }
        }

Many Thanks,
Mostafa Nabil

mostafa340
 
Posts: 2
Joined: Thu Oct 21, 2021 7:14 pm

Mon Oct 25, 2021 7:36 am

Dear Mostafa,

Thanks for your feedback.
Yes, after doing multiple connections, I indeed found that sometimes the connection was failed with the error. This may be related to instable network. Anyway, our Dev team will do a further investigation to check if there is any other reasons. Once there is any update, we will let you know asap. Sorry for the inconvenience caused.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Email