Java
Java
Send a POP3 NOOP Command
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3Noop method, which sends a POP3 NOOP command to the server. NOOP does nothing except elicit a positive response, which is useful for keeping a session alive or verifying the connection is still responsive. This example begins a POP3 session and sends a NOOP.
Background:
NOOP ("no operation") is a standard keep-alive across many internet protocols. Servers often drop idle connections after a timeout; sending a periodic NOOP resets that timer so a long-running session stays open. It also serves as a cheap "are you still there?" probe — a successful reply confirms the socket and the authenticated session are still healthy.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.Pop3Noop method, which sends a POP3 NOOP command to the server.
// NOOP does nothing except elicit a positive response, which is useful for keeping a
// session alive or verifying the connection is still responsive.
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");
// Begin a POP3 session.
success = mailman.Pop3BeginSession();
if (success == false) {
System.out.println(mailman.lastErrorText());
return;
}
// Send a NOOP to keep the session alive.
success = mailman.Pop3Noop();
if (success == false) {
System.out.println(mailman.lastErrorText());
return;
}
System.out.println("POP3 NOOP succeeded.");
}
}