Java
Java
End a POP3 Session (Commit Deletions)
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3EndSession method, which ends the current POP3 session by sending the QUIT command. Ending the session normally commits any messages that were marked for deletion during the session. This example begins a session and then ends it.
Background: POP3 deletion is deferred:
DELE commands only mark messages during the session, and the server permanently removes them when the client sends QUIT to end the session cleanly. Pop3EndSession is that commit point. If a session is dropped without QUIT (see Pop3EndSessionNoQuit), the server rolls back the pending deletions and the messages remain.Chilkat Java Downloads
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
boolean success = false;
// Demonstrates the MailMan.Pop3EndSession method, which ends the current POP3 session by
// sending the QUIT command. Ending the session normally commits any messages that were
// marked for deletion during the session.
CkMailMan mailman = new CkMailMan();
// Configure the POP3 server connection.
mailman.put_MailHost("pop.example.com");
mailman.put_MailPort(995);
mailman.put_PopSsl(true);
mailman.put_PopUsername("user@example.com");
mailman.put_PopPassword("myPassword");
// Explicitly begin a POP3 session.
success = mailman.Pop3BeginSession();
if (success == false) {
System.out.println(mailman.lastErrorText());
return;
}
// ... perform mailbox operations here, such as fetching or marking messages for deletion ...
// End the POP3 session (sends QUIT), committing any pending deletions.
success = mailman.Pop3EndSession();
if (success == false) {
System.out.println(mailman.lastErrorText());
return;
}
System.out.println("POP3 session ended.");
}
}