Using the PopSsl class |
The PopSsl class provides an easy to use client interface for securely communicating with POP3 servers using SSL/TLS. The PopSsl class provides both implicit and explicit SSL/TLS connections. Implicit SSL/TLS connections are made by default using remote port 995. Explicit SSL/TLS connections are made using an unencrypted connection to port 110 of a POP3 server and then switching to an encrypted mode using the STLS command prior to sending any additional data.
Example
The example below demonstrates connecting using implicit SSL/TLS on port 995
// create new PopSsl instance PopSsl ssl = new PopSsl(hostname,995,username,password);
// establish SSL/TLS connection ssl.connect();
// get messages and print subject Enumeration e = ssl.getMessages(); while(e.hasMoreElements()) { EmailMessage msg = (EmailMessage)e.nextElement(); System.out.println("Subject: " + msg.getSubject()); }
// disconnect ssl.disconnect();
Example
The example below demonstrates connecting using explicit SSL/TLS and STLS command on port 110.
// create new PopSsl instance PopSsl ssl = new PopSsl(hostname,110,username,password);
// set connection type ssl.setConnectionType(PopSsl.STARTTLS);
// establish SSL/TLS connection ssl.connect();
// get messages and print subject Enumeration e = ssl.getMessages(); while(e.hasMoreElements()) { EmailMessage msg = (EmailMessage)e.nextElement(); System.out.println("Subject: " + msg.getSubject()); }
// disconnect ssl.disconnect();
|