Using the ImapSsh class |
The ImapSsh class is a subclass of the com.jscape.inet.imap.Imap class. It provides access to all the same features as the Imap class with the exception that all data is securely tunneled thru an SSH server. To use the ImapSsh class create a new ImapSsh instance providing a com.jscape.inet.ssh.util.SshParameters instance as an argument to the constructor.
Example
// connection information for SSH server String sshHostname = "imap4.myserver.com"; String sshUsername = "jsmith"; String sshPassword = "secret";
// create new SshParameters instance SshParameters sshParams = new SshParameters(sshHostname,sshUsername,sshPassword);
// new instance with SSH parameters hostname, username and password ImapSsh imap = new ImapSsh(sshParams,"imap4.myserver.com","jsmith","secret"); try { // connect to IMAP4 server imap.connect();
// get messages int messageCount = imap.getMessageCount(); for(int i = 1; i <= messageCount(); ++i) { EmailMessage em = imap.getMessage(i); }
// disconnect imap.disconnect(); } catch(Exception e) { System.out.println(e); } |