public class SmtpSsh extends Smtp
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);
}
Smtp.AuthenticationAUTH_CRAM_MD5, AUTH_LOGIN, AUTH_XOAUTH2| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
SmtpSsh |
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.
|
addSmtpListener, clearProxySettings, close, getAuthentication, getConnectTimeout, getDebugStream, getHostname, getPort, getReadTimeout, getTimeout, isConnected, isDebug, issueCommand, login, login, login, removeSmtpListener, send, send, send, setAuthentication, setConnectTimeout, setDebug, setDebugStream, setHeloAddress, setHostname, setPort, setProxyAuthentication, setProxyHost, setProxyType, setReadTimeout, setTimeoutpublic SmtpSsh(java.lang.String hostname)
hostname - the SMTP server hostnamepublic SmtpSsh(SshParameters sshParameters, java.lang.String hostname)
hostname - the SMTP server hostnamesshParameters - the SSH parameters used in establishing secure connectionpublic SmtpSsh()
public SmtpSsh connect() throws SmtpException
connect in class SmtpSmtpException - thrown for I/O or SMTP related errorpublic void disconnect()
throws SmtpException
disconnect in class SmtpSmtpException - thrown to handle SMTP and I/O related errorsSmtpExceptionpublic SshParameters getSshParameters()
SshParameterspublic void setSshParameters(SshParameters parameters)
parameters - the SSH parametersSshParametersCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved