Keel 2.1RC2

org.keel.services.mail.javamail
Class DefaultMailer

java.lang.Object
  extended byorg.keel.services.mail.javamail.DefaultMailer
All Implemented Interfaces:
Configurable, LogEnabled, Mailer

public class DefaultMailer
extends java.lang.Object
implements Mailer, Configurable, LogEnabled

This service implements the Keel Mailer service. It provides the capability to send email via an SMTP server. This service supports both a standard and an authenticated SMTP session. The typical configuration for this service is as follows:

        
                                mail.attbi.com
                                true
                                username>
                                password
                                true
                                myuser@myhost.com
                                [EMPTY SUBJECT]
        
 

Version:
$Revision: 1.5 $ $Date: 2003/10/10 23:12:58 $
Author:
Shash Chatterjee Created on Jan 1, 2003

Field Summary
private  java.lang.String[] attachments
          Name of file(s) for MIME attachment(s)
private  InternetAddress[] bccAddress
          Address(es) to send blind-carbon-copy to
private  InternetAddress[] ccAddress
          Address(es) to send carbon-copy to
private  Configuration configuration
          The configuraton for this service - from mailer-system.xconf
private  java.lang.String defaultFrom
          From address to use, if none provided
private  java.lang.String defaultSubject
           
private  InternetAddress fromAddress
          Sender's address
private  java.util.Vector headers
          Headers to add
private  Logger logger
          The logger for info/debug messages
private  boolean mailAuth
          SMTP server requires authentication
private  boolean mailDebug
          Turn on JavaMail session debug
private  java.lang.String mailHost
          The SMTP host
private  java.lang.String mailPassword
          Password for SMTP authentication
private  java.lang.String mailUser
          Username for SMTP authentication
private  java.lang.String message
          Text message
private  InternetAddress[] replyToAddress
          Address(es) to send reply to
private  java.lang.String subject
          Email subject
private  InternetAddress[] toAddress
          Address(es) to send to
 
Fields inherited from interface org.keel.services.mail.Mailer
ROLE
 
Constructor Summary
DefaultMailer()
           
 
Method Summary
 void addMIMEAttachment(java.lang.String fileName)
          Add a MIME attachment, MIME-type will be determined automatically by the system
 void addMIMEAttachment(java.lang.String[] fileNames)
          Add multiple MIME attachments
 void configure(Configuration configuration)
          This method reads the container-provided configuration
 void enableLogging(Logger logger)
          This method associates this service with a logger
 void send()
          Send the email to the mail-server
 void send(java.lang.String host, java.lang.String user, java.lang.String password)
          Send mail to a different host with a different user and password
 void setBccAddress(java.lang.String address)
          Set the blind-carbon-copy addresses for this email
 void setBccAddress(java.lang.String[] addresses)
          Set multiple blibd-carbon-copy addresses
 void setCcAddress(java.lang.String address)
          Set the carbon-copy address for this email
 void setCcAddress(java.lang.String[] addresses)
          Set multiple carbon-copy addresses
 void setFromAddress(java.lang.String address)
          Set the address of the sender of the email
 void setHeader(java.lang.String name, java.lang.String value)
          Set an arbitrary header
 void setMessage(java.lang.String message)
          Set the text content of the email, weill be sent as first attachment
 void setReplyToAddress(java.lang.String address)
          Set the reply-to header in the email, usually if different from the sender's email.
 void setReplyToAddress(java.lang.String[] addresses)
          Set multiple reply-to addresses
 void setSubject(java.lang.String subject)
          Set the subject of the email
 void setToAddress(java.lang.String address)
          The address to send email
 void setToAddress(java.lang.String[] addresses)
          Set the addresses to send email to
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private Logger logger
The logger for info/debug messages


configuration

private Configuration configuration
The configuraton for this service - from mailer-system.xconf


mailHost

private java.lang.String mailHost
The SMTP host


mailDebug

private boolean mailDebug
Turn on JavaMail session debug


mailAuth

private boolean mailAuth
SMTP server requires authentication


mailUser

private java.lang.String mailUser
Username for SMTP authentication


mailPassword

private java.lang.String mailPassword
Password for SMTP authentication


defaultFrom

private java.lang.String defaultFrom
From address to use, if none provided


defaultSubject

private java.lang.String defaultSubject

toAddress

private InternetAddress[] toAddress
Address(es) to send to


ccAddress

private InternetAddress[] ccAddress
Address(es) to send carbon-copy to


bccAddress

private InternetAddress[] bccAddress
Address(es) to send blind-carbon-copy to


fromAddress

private InternetAddress fromAddress
Sender's address


replyToAddress

private InternetAddress[] replyToAddress
Address(es) to send reply to


headers

private java.util.Vector headers
Headers to add


attachments

private java.lang.String[] attachments
Name of file(s) for MIME attachment(s)


subject

private java.lang.String subject
Email subject


message

private java.lang.String message
Text message

Constructor Detail

DefaultMailer

public DefaultMailer()
Method Detail

addMIMEAttachment

public void addMIMEAttachment(java.lang.String fileName)
                       throws NestedException
Description copied from interface: Mailer
Add a MIME attachment, MIME-type will be determined automatically by the system

Specified by:
addMIMEAttachment in interface Mailer
Parameters:
fileName -
Throws:
NestedException
See Also:
Mailer.addMIMEAttachment(java.lang.String)

addMIMEAttachment

public void addMIMEAttachment(java.lang.String[] fileNames)
                       throws NestedException
Description copied from interface: Mailer
Add multiple MIME attachments

Specified by:
addMIMEAttachment in interface Mailer
Parameters:
fileNames -
Throws:
NestedException
See Also:
org.keel.services.mail.Mailer#addMIMEAttachmentList(java.util.Vector)

send

public void send()
          throws NestedException
Description copied from interface: Mailer
Send the email to the mail-server

Specified by:
send in interface Mailer
Throws:
NestedException

send

public void send(java.lang.String host,
                 java.lang.String user,
                 java.lang.String password)
          throws NestedException
Description copied from interface: Mailer
Send mail to a different host with a different user and password

Specified by:
send in interface Mailer
Parameters:
host -
user -
password -
Throws:
NestedException
See Also:
Mailer.send()

setBccAddress

public void setBccAddress(java.lang.String address)
                   throws NestedException
Description copied from interface: Mailer
Set the blind-carbon-copy addresses for this email

Specified by:
setBccAddress in interface Mailer
Parameters:
address -
Throws:
NestedException
See Also:
Mailer.setBccAddress(java.lang.String)

setBccAddress

public void setBccAddress(java.lang.String[] addresses)
                   throws NestedException
Description copied from interface: Mailer
Set multiple blibd-carbon-copy addresses

Specified by:
setBccAddress in interface Mailer
Parameters:
addresses -
Throws:
NestedException
See Also:
org.keel.services.mail.Mailer#setBccAddressList(java.util.Vector)

setCcAddress

public void setCcAddress(java.lang.String address)
                  throws NestedException
Description copied from interface: Mailer
Set the carbon-copy address for this email

Specified by:
setCcAddress in interface Mailer
Parameters:
address -
Throws:
NestedException
See Also:
Mailer.setCcAddress(java.lang.String)

setCcAddress

public void setCcAddress(java.lang.String[] addresses)
                  throws NestedException
Description copied from interface: Mailer
Set multiple carbon-copy addresses

Specified by:
setCcAddress in interface Mailer
Parameters:
addresses -
Throws:
NestedException
See Also:
org.keel.services.mail.Mailer#setCcAddressList(java.util.Vector)

setFromAddress

public void setFromAddress(java.lang.String address)
                    throws NestedException
Description copied from interface: Mailer
Set the address of the sender of the email

Specified by:
setFromAddress in interface Mailer
Parameters:
address -
Throws:
NestedException
See Also:
Mailer.setFromAddress(java.lang.String)

setReplyToAddress

public void setReplyToAddress(java.lang.String address)
                       throws NestedException
Description copied from interface: Mailer
Set the reply-to header in the email, usually if different from the sender's email.

Specified by:
setReplyToAddress in interface Mailer
Parameters:
address -
Throws:
NestedException
See Also:
Mailer.setReplyToAddress(java.lang.String)

setReplyToAddress

public void setReplyToAddress(java.lang.String[] addresses)
                       throws NestedException
Description copied from interface: Mailer
Set multiple reply-to addresses

Specified by:
setReplyToAddress in interface Mailer
Parameters:
addresses -
Throws:
NestedException
See Also:
Mailer.setReplyToAddress(java.lang.String)

setMessage

public void setMessage(java.lang.String message)
                throws NestedException
Description copied from interface: Mailer
Set the text content of the email, weill be sent as first attachment

Specified by:
setMessage in interface Mailer
Parameters:
message -
Throws:
NestedException
See Also:
Mailer.setMessage(java.lang.String)

setSubject

public void setSubject(java.lang.String subject)
                throws NestedException
Description copied from interface: Mailer
Set the subject of the email

Specified by:
setSubject in interface Mailer
Parameters:
subject -
Throws:
NestedException
See Also:
Mailer.setSubject(java.lang.String)

setToAddress

public void setToAddress(java.lang.String address)
                  throws NestedException
Description copied from interface: Mailer
The address to send email

Specified by:
setToAddress in interface Mailer
Parameters:
address - A standard address, or a comma-separated list of addresses
Throws:
NestedException
See Also:
Mailer.setToAddress(java.lang.String)

setToAddress

public void setToAddress(java.lang.String[] addresses)
                  throws NestedException
Description copied from interface: Mailer
Set the addresses to send email to

Specified by:
setToAddress in interface Mailer
Parameters:
addresses - An array of String addresses
Throws:
NestedException
See Also:
org.keel.services.mail.Mailer#setToAddressList(java.util.Vector)

configure

public void configure(Configuration configuration)
               throws ConfigurationException
This method reads the container-provided configuration

Specified by:
configure in interface Configurable
Parameters:
configuration - the class configurations. Must not be null.
Throws:
ConfigurationException - if an error occurs
See Also:
Configurable.configure(org.apache.avalon.framework.configuration.Configuration)

enableLogging

public void enableLogging(Logger logger)
This method associates this service with a logger

Specified by:
enableLogging in interface LogEnabled
Parameters:
logger - the logger. Must not be null.
See Also:
LogEnabled.enableLogging(org.apache.avalon.framework.logger.Logger)

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
               throws NestedException
Description copied from interface: Mailer
Set an arbitrary header

Specified by:
setHeader in interface Mailer
Parameters:
name -
value -
Throws:
NestedException
See Also:
org.keel.services.mail.Mailer#Header(java.lang.String, java.lang.String)

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.