org.sandev.tools.util
Class DefaultMailSender

java.lang.Object
  extended byorg.sandev.tools.util.DefaultMailSender
All Implemented Interfaces:
org.sandev.basics.util.SimpleMailSender

public class DefaultMailSender
extends java.lang.Object
implements org.sandev.basics.util.SimpleMailSender

A default smtp mail sender implementation.


Field Summary
protected  javax.mail.Session session
          The session we are using.
 
Constructor Summary
DefaultMailSender()
           
 
Method Summary
protected  void debug(java.lang.String text)
          Used to create debug output.
 boolean getDebugFlag()
          accessor for debugFlag
 javax.mail.Session getSession()
          accessor for session
 void init(java.lang.String host, java.lang.String username, java.lang.String password, boolean debugFlag)
          Initialize this instance.
 void send(java.lang.String sender, java.lang.String recipient, java.lang.String subject, java.lang.String content)
          Check for multiple recipients and then call sendSingle for each recipient found.
 void sendSingle(java.lang.String sender, java.lang.String recipient, java.lang.String subject, java.lang.String content)
          Send the specified message.
 void setDebugFlag(boolean val)
          mutator for debugFlag
 void setSession(javax.mail.Session val)
          mutator for session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected javax.mail.Session session
The session we are using. We store this so we don't need to reinit each call.

Constructor Detail

DefaultMailSender

public DefaultMailSender()
Method Detail

getSession

public javax.mail.Session getSession()
accessor for session


setSession

public void setSession(javax.mail.Session val)
mutator for session


getDebugFlag

public boolean getDebugFlag()
accessor for debugFlag


setDebugFlag

public void setDebugFlag(boolean val)
mutator for debugFlag


init

public void init(java.lang.String host,
                 java.lang.String username,
                 java.lang.String password,
                 boolean debugFlag)
          throws org.sandev.basics.util.MailException
Initialize this instance. If debug is true, then provide whatever trace information is possible, otherwise run quietly.

Specified by:
init in interface org.sandev.basics.util.SimpleMailSender
Throws:
org.sandev.basics.util.MailException

send

public void send(java.lang.String sender,
                 java.lang.String recipient,
                 java.lang.String subject,
                 java.lang.String content)
          throws org.sandev.basics.util.MailException
Check for multiple recipients and then call sendSingle for each recipient found.

Specified by:
send in interface org.sandev.basics.util.SimpleMailSender
Throws:
org.sandev.basics.util.MailException

sendSingle

public void sendSingle(java.lang.String sender,
                       java.lang.String recipient,
                       java.lang.String subject,
                       java.lang.String content)
                throws org.sandev.basics.util.MailException
Send the specified message. If the text you are sending contains "<a href" or "<A HREF" then the mail is sent as text/html. Otherwise it is sent as text/plain.

Throws:
org.sandev.basics.util.MailException

debug

protected void debug(java.lang.String text)
Used to create debug output. Thin wrapper around System.out.println.