Question

I'm having trouble with POP3 Client in delphi (indy). I can use some functionality only once after connecting to a POP3Server - the first time i type :

POP3Client.Connect

(with username, password, etc..) everything is just fine.But the second time I get message 'Already connected' and nothing like checkmessages, retrieveHeader, retrieve works.And if I try

POP3Client.Disconnect

it gives me an error 'Connection closed gracefully'. Can anyone help me with this ?

Was it helpful?

Solution

Disconnect() sends a QUIT command to the server by default, which will fail if the connection has already been lost. If you are calling Disconnect() after a previous socket error occurred, pass false to the ANotifyPeer parameter of Disconnect() to bypass the QUIT command:

POP3Client.Disconnect(false);

Do note that bypassing the QUIT prevents the server from entering the UPDATE state, so if you had previously called Delete() then those messages will not be removed from the server, as deletion only occurrs during the UPDATE state. Use ANotifyPeer=false only during error handling, use ANotifyPeer=true during normal operation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top