3

I am using OpenPop.Net to connect to a GoDaddy hosted email account in a C# application. The Authenticate() method throws an exception with the error message of "The stream used to retrieve responses from was closed". I doubled checked that the POPServer, POPPort, POPUserName, and POPPassword values were valid using Outlook 2007.

using (Pop3Client pop3 = new Pop3Client())
{
    pop3.Connect(POPServer, POPPort, false);
    pop3.Authenticate(POPUserName, POPPassword);

    Int32 messageCount = pop3.GetMessageCount();
}
laylarenee
  • 3,276
  • 7
  • 32
  • 40
Frank Perez
  • 993
  • 8
  • 18

1 Answers1

11

The Authenticate() method supports a 3rd parameter, an enumeration called AuthenticationMethod. According to the help file, if the 3rd parameter is not passed the Authenticate() method defaults to an authentication method of Auto. The help file goes on to say that the Auto method is the recommended method to authenticate with. If Apop is supported by the server, Apop is used for authentication. If Apop is not supported, Auto will fall back to UsernameAndPassword authentication.

I tried explicitly passing Auto, and the Authenticate() method failed with the same error. I then tried explicitly passing UsernameAndPassword, this time it worked. I'm not sure if this is a bug in OpenPop.Net or a problem with the POP server. Here is the working code.

using (Pop3Client pop3 = new Pop3Client())
{
    pop3.Connect(POPServer, POPPort, false);
    pop3.Authenticate(POPUserName, POPPassword, AuthenticationMethod.UsernameAndPassword);

    Int32 messageCount = pop3.GetMessageCount();
}
Frank Perez
  • 993
  • 8
  • 18
  • 3
    Hi. I am a developer of OpenPop. This is a know problem. The thing is that the POP3 server properly tells the POP3 client (here OpenPop) that it supports APOP - but actually does not, therefore failing when the server tries to login using the APOP method. The majority of servers, as far as I know, correctly tells the client if it supports APOP or not. Good that you found the solution yourself. Maybe a comment in the help file would help the next person having your problem. Will do :) – foens Aug 05 '11 at 18:09