Secure iNet Factory

com.jscape.inet.smtpssh
Class SmtpSsh

java.lang.Object
  extended by com.jscape.inet.smtp.Smtp
      extended by com.jscape.inet.smtpssh.SmtpSsh
All Implemented Interfaces:
java.io.Serializable

public class SmtpSsh
extends Smtp

Implements the basic functionality of a SMTP client tunnelling all data through a secure SSH connection.

Example Usage:

 // 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:
Serialized Form

Field Summary
 
Fields inherited from class com.jscape.inet.smtp.Smtp
AUTH_CRAM_MD5, AUTH_LOGIN
 
Constructor Summary
SmtpSsh()
          Creates a new SmtpSsh instance.
SmtpSsh(SshParameters sshParameters, java.lang.String hostname)
          Creates a new SmtpSsh instance.
SmtpSsh(java.lang.String hostname)
          Creates a new SmtpSsh instance.
 
Method Summary
 void connect()
          Connects to SMTP server tunnelling data through SSH server.
 void disconnect()
          Disconnects from SMTP and SSH servers.
 SshParameters getSshParameters()
          Gets SSH parameters used in establishing connection with SSH server.
 void setSshParameters(SshParameters parameters)
          Sets SSH parameters used in establishing connection with SSH server.
 
Methods inherited from class com.jscape.inet.smtp.Smtp
addSmtpListener, clearProxySettings, getConnectTimeout, getDebugStream, getHostname, getPort, getReadTimeout, getTimeout, isConnected, isDebug, issueCommand, login, login, main, removeSmtpListener, send, send, send, setConnectTimeout, setDebug, setDebugStream, setHeloAddress, setHostname, setPort, setProxyAuthentication, setProxyHost, setProxyType, setReadTimeout, setTimeout
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmtpSsh

public SmtpSsh(java.lang.String hostname)
Creates a new SmtpSsh instance.

Parameters:
hostname - the SMTP server hostname

SmtpSsh

public SmtpSsh(SshParameters sshParameters,
               java.lang.String hostname)
Creates a new SmtpSsh instance.

Parameters:
hostname - the SMTP server hostname
sshParameters - the SSH parameters used in establishing secure connection

SmtpSsh

public SmtpSsh()
Creates a new SmtpSsh instance.

Method Detail

connect

public void connect()
             throws SmtpException
Connects to SMTP server tunnelling data through SSH server.

Overrides:
connect in class Smtp
Throws:
SmtpException - thrown for I/O or SMTP related error

disconnect

public void disconnect()
                throws SmtpException
Disconnects from SMTP and SSH servers.

Overrides:
disconnect in class Smtp
Throws:
SmtpException - thrown to handle SMTP and I/O related errors
See Also:
SmtpException

getSshParameters

public SshParameters getSshParameters()
Gets SSH parameters used in establishing connection with SSH server.

Returns:
the SSH parameters
See Also:
SshParameters

setSshParameters

public void setSshParameters(SshParameters parameters)
Sets SSH parameters used in establishing connection with SSH server.

Parameters:
parameters - the SSH parameters
See Also:
SshParameters

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved