Question:
Greetings,
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.UnlockComponent(EmailKey);
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);
ChilkatLog:
GetAllHeaders:
DllDate: Aug 28 2012
UnlockPrefix: CHRISTMAILQ
Username: PC111:ckersey
Architecture: Little Endian; 64-bit
Language: .NET 4.5 / x64
VerboseLogging: 1
Pop3Connect:
Connecting to POP3 server
hostname: 10.1.1.242
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...
AddrInfoList:
AddrInfo:
ai_flags: 4
ai_family: 2
ai_socktype: 1
ai_protocol: 0
ai_addrlen: 16
ai_canonname: (NULL)
--AddrInfo
--AddrInfoList
Connect using IPV4.
ipAddress1: 10.1.1.242
myIP_3: 10.1.1.111
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
--Pop3Connect
Pop3Authenticate:
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
--Pop3Authenticate
Authentication failed.
Failed to ensure transaction state.
--GetAllHeaders
--ChilkatLog
Any suggestions to help me get past his obstacle?
Chris,
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.