adams.core.net
Class ApacheSendEmail

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.core.net.AbstractSendEmail
              extended by adams.core.net.ApacheSendEmail
All Implemented Interfaces:
Debuggable, Destroyable, OptionHandler, SizeOfHandler, Serializable

public class ApacheSendEmail
extends AbstractSendEmail

Uses Apache commons-net SMTPClient or SMTPSClient for sending emails.

Version:
$Revision: 7123 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  org.apache.commons.net.smtp.SMTPClient m_Client
          the SMTP client.
protected  BasePassword m_Password
          the password to use for authentication.
protected  int m_Port
          the server port.
protected  boolean m_RequiresAuth
          whether authentication is required.
protected  String m_Server
          the server to connect to.
protected  int m_Timeout
          the timeout for the server.
protected  String m_User
          the user to use for authenticating.
protected  boolean m_UseTLS
          whether to use TLS.
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
ApacheSendEmail()
           
 
Method Summary
 String globalInfo()
          Returns a string describing the object.
 void initializeSmtpSession(String server, int port, boolean useTLS, int timeout, boolean requiresAuth, String user, BasePassword pw)
          Initializes the SMTP session.
 boolean requiresSmtpSessionInitialization()
          Returns whether the SMTP session needs to be initialized.
 boolean sendMail(Email email)
          Sends an email.
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, defineOptions, destroy, finishInit, getDebugLevel, getOptionManager, initialize, isDebugOn, newOptionManager, reset, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Client

protected transient org.apache.commons.net.smtp.SMTPClient m_Client
the SMTP client.


m_Server

protected String m_Server
the server to connect to.


m_Port

protected int m_Port
the server port.


m_UseTLS

protected boolean m_UseTLS
whether to use TLS.


m_Timeout

protected int m_Timeout
the timeout for the server.


m_RequiresAuth

protected boolean m_RequiresAuth
whether authentication is required.


m_User

protected String m_User
the user to use for authenticating.


m_Password

protected BasePassword m_Password
the password to use for authentication.

Constructor Detail

ApacheSendEmail

public ApacheSendEmail()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

requiresSmtpSessionInitialization

public boolean requiresSmtpSessionInitialization()
Returns whether the SMTP session needs to be initialized.

Specified by:
requiresSmtpSessionInitialization in class AbstractSendEmail
Returns:
true if the SMTP session needs to be initialized

initializeSmtpSession

public void initializeSmtpSession(String server,
                                  int port,
                                  boolean useTLS,
                                  int timeout,
                                  boolean requiresAuth,
                                  String user,
                                  BasePassword pw)
                           throws Exception
Initializes the SMTP session.

Specified by:
initializeSmtpSession in class AbstractSendEmail
Parameters:
server - the SMTP server
port - the SMTP port
useTLS - whether to use TLS
timeout - the timeout
requiresAuth - whether authentication is required
user - the SMTP user
pw - the SMTP password
Throws:
Exception - if initialization fails

sendMail

public boolean sendMail(Email email)
                 throws Exception
Sends an email.

Specified by:
sendMail in class AbstractSendEmail
Parameters:
email - the email to send
Returns:
true if successfully sent
Throws:
Exception - in case of invalid internet addresses or messaging problem


Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.