login about faq


I wrote an application that polls an inbox for attachments to download and process. I'm re-writing the application to be more robust, and so I decided to give chilkat a try (as opposed to another component I was using).

I've set up a class file to wrap up some of the functionality such as initialization. In my initialization, I assigned all of the basic connection commands and verified the values were correct (per my previous project that worked fine - connection settings, etc.).

        mailman.MailHost = POPServer;
        mailman.MailPort = POPPort;
        mailman.PopUsername = POPLogin;
        mailman.PopPassword = POPPassw;

When attempting to log-in to the same Exchange Server (2010) set up in my prior project, I am met with an "-ERR Command is not valid in this state" in the following call:

        Chilkat.EmailBundle emails = mailman.GetAllHeaders(1);

    DllDate: Aug 28 2012
    UnlockPrefix: CHRISTMAILQ
    Username: PC111:ckersey
    Architecture: Little Endian; 64-bit
    Language: .NET 4.5 / x64
     VerboseLogging: 1
  Connecting to POP3 server
  port: 110
  ssl: 0
  connectTimeoutMs: 30000
  heartbeatMs: 0
  ConnectTimeoutMs_1: 30000
  calling ConnectSocket2
  IPV6 enabled connect with NO heartbeat.
  This is an IPV4 numeric address...
      ai_flags: 4
      ai_family: 2
      ai_socktype: 1
      ai_protocol: 0
      ai_addrlen: 16
      ai_canonname: (NULL)
      Connect using IPV4.
      myPort_3: 51028
      connect successful (2)
      Connected to POP3 server
      PopCmdResp: +OK The Microsoft Exchange POP3 service is ready.
      greeting: +OK The Microsoft Exchange POP3 service is ready.
      ConnectionType: Unencrypted TCP/IP
      username: quotereport
      popSPA: 0
      PopCmdSent: USER quotereport
      PopCmdResp: -ERR Command is not valid in this state.
      POP3 response indicates failure.
      USER_response: -ERR Command is not valid in this state.

      POP3 authentication failed
    Authentication failed.
    Failed to ensure transaction state.

Any suggestions to help me get past his obstacle?

asked Apr 03 '13 at 19:50

SirJamsalot's gravatar image



Thanks for posting! The "Command is not valid in this state" is the cryptic and confusing way that MS Exchange is trying to say "I'm not configured to allow for passwords to be sent unencrypted over the network."

The solution is to make sure the connection is SSL/TLS. As with most other protocols, this can be done "implicitly" or "explicitly". Implicit means that you'll connect to the server's alternative port for SSL/TLS connections. For POP3, the standard port for implicit SSL/TLS connections is 995. When connecting to the implicit SSL/TLS port, the SSL/TLS channel is immediately (implicitly) established. The Chilkat properties to set for POP3 implicit SSL are MailPort (set equal to 995) and PopSsl (set equal to True).

Explicit means that you'll connect to the standard unencrypted port, and then a command is sent to explicitly convert the unencrypted TCP/IP connection to a secure SSL/TLS channel. To do this in Chilkat, leave PopSsl = False, but set the Pop3Stls property = True. Chilkat will automatically convert the connection to SSL/TLS after connecting.

Another possible option is to use Secure Password Authentication (SPA). This allows for the connection to remain unencrypted, but the authentication uses a protocol (such as NTLM) where the password is never actually sent over the network. These authentication protocols work by doing a quick back-and-forth exchange of information that allows the server to know that the client is in possession of the correct password.


answered Apr 04 '13 at 09:10

chilkat's gravatar image

chilkat ♦♦

Well, I feel somewhat silly at this point. I knew SSL was an option, but didn't bother to try it because the other application worked fine without it! Thanks for the quick reply on this!

(Apr 04 '13 at 12:54) SirJamsalot
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Apr 03 '13 at 19:50

Seen: 12,570 times

Last updated: Apr 04 '13 at 12:54

powered by OSQA