Sample code for 30+ languages & platforms
Java

Authenticate with the POP3 Server

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3Authenticate method, which authenticates with the POP3 server using the current POP3 property settings, such as PopUsername and PopPassword. It is typically called after Pop3Connect. This example connects and then authenticates.

Background: POP3 authentication is the step, after connecting, where the client identifies itself — classically with the USER and PASS commands, or a more secure mechanism. Calling Pop3Connect and Pop3Authenticate as distinct steps lets you determine precisely which phase fails, and lets you hold an authenticated session open to perform several mailbox operations before ending it with Pop3EndSession.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.MailMan;

public class ChilkatExample {

    public static void main(String[] args) {
        // Demonstrates the MailMan.Pop3Authenticate method, which authenticates with the POP3 server
        // using the current POP3 property settings (such as PopUsername and PopPassword).  It is
        // typically called after Pop3Connect.

        MailMan mailman = new MailMan();

        // Configure the POP3 server connection.
        mailman.setMailHost("pop.example.com");
        mailman.setMailPort(995);
        mailman.setPopSsl(true);
        mailman.setPopUsername("user@example.com");
        mailman.setPopPassword("myPassword");

        // Connect first, then authenticate.

        try {
            mailman.pop3Connect();

            mailman.pop3Authenticate();
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println("Authenticated with the POP3 server.");
    }
}