Using the SmtpSsh class |
The SmtpSsh class is a subclass of the com.jscape.inet.smtp.Smtp class. It provides access to all the same features as the Smtp class with the exception that all data is securely tunneled thru an SSH server. To use the SmtpSsh class create a new SmtpSsh instance providing a com.jscape.inet.ssh.util.SshParameters instance as an argument to the constructor. See the JavaDoc reference for more details on using the SshParameters class.
Example
// connection parameters for SSH server String sshHostname = "smtp.myserver.com"; String sshUsername = "jsmith"; String sshPassword = "secret";
// create new SshParameters instance SshParameters sshParams = new SshParameters(sshHostname,sshUsername,sshPassword);
// create new instance SmtpSsh smtp = new SmtpSsh(sshParams, "smtp.myserver.com");
// address the message EmailMessage message = new EmailMessage(); message.setTo("mjones@myserver.com"); message.setFrom("jsmith@myserver.com"); message.setSubject("Meeting today at 8"); message setBody("see you then");
// connect, send the message, disconnect try { smtp.connect(); smtp.send(message); smtp.disconnect(); } catch(Exception e) { System.out.println(e); }
See also
|