org.davesag.generica.util
Class Mailer

java.lang.Object
  extended byorg.davesag.generica.util.Mailer

public class Mailer
extends Object

This is a general purpose class for setting up standard email messages using the javax mail API.

Since:
Generica 1.0
Version:
CVS Revision $Id: Mailer.java,v 1.7 2004/03/30 13:00:43 davesag Exp $
Author:
Dave Sag http://www.davesag.com

Field Summary
protected  boolean isAuthenticating
           
protected  String theAuthenticatedPassword
           
protected  String theAuthenticatedUser
           
protected  List theBcc
           
protected  List theCc
           
protected  List theFiles
           
protected  String theFrom
           
protected  Map theHeaders
           
protected  String theHost
           
protected  Properties theMailProps
           
protected  javax.mail.Session theMailSession
           
protected  javax.mail.Message theMessage
           
protected  List theMessages
           
protected  List theReplyTo
           
protected  List theSig
           
protected  String theSubject
           
protected  List theTo
           
protected  List theUris
           
 
Constructor Summary
Mailer()
          No arg constructor.
 
Method Summary
 void addBcc(String bcc)
          Adds an email address to the bcc field of the mail message
 void addBCC(String[] bcc)
          Adds an array of bcc addresses to the mail message.
 void addCc(String cc)
          Add a CC address to the message.
 void addCcs(String[] ccs)
          Add an array of CC address to the message.
 void addEncloseFile(String file)
          Adds an enclosure file to the message
 void addEncloseFiles(String[] files)
          Adds an array of enclosure files to the message.
 void addEncloseUri(String uri)
          Adds an enclosure uri to the message.
 void addEncloseUris(String[] uris)
          Adds an array of enclosure uris to the message.
 void addHeader(String name, String value)
          Adds header parameters to a Map of headers.
 void addMessage(String msg)
          Adds a message that is apppended in sequence to the message body.
 void addMessages(String[] msg)
          Adds an arrays of message strings to the message body.
 void addReplyTo(String replyto)
          Adds a reply-to addresses to the mail message.
 void addSignature(String sig)
          Adds a signature text for the message.
 void addTo(String to)
          Add a TO address to the message.
 void addTos(String[] tos)
          Adds an array of To addresses to the message.
 boolean sendMail()
          Send the email.
 void setAuthentication(String username, String password)
          sets the authentication username and password.
 void setDebug(String debug)
          Sets the debug mode
 void setFrom(String from)
          Sets the from address.
 void setHost(String host)
          Sets the SMTP server to use.
 void setSubject(String subject)
          Sets the subject text for the message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theAuthenticatedUser

protected String theAuthenticatedUser

theAuthenticatedPassword

protected String theAuthenticatedPassword

isAuthenticating

protected boolean isAuthenticating

theFrom

protected String theFrom

theHost

protected String theHost

theSubject

protected String theSubject

theMailProps

protected Properties theMailProps

theMailSession

protected javax.mail.Session theMailSession

theMessage

protected javax.mail.Message theMessage

theHeaders

protected Map theHeaders

theReplyTo

protected List theReplyTo

theTo

protected List theTo

theCc

protected List theCc

theBcc

protected List theBcc

theMessages

protected List theMessages

theUris

protected List theUris

theFiles

protected List theFiles

theSig

protected List theSig
Constructor Detail

Mailer

public Mailer()
No arg constructor.

Method Detail

sendMail

public boolean sendMail()
Send the email.

Returns:
true if the email was sent okay.

setHost

public void setHost(String host)
Sets the SMTP server to use.

Parameters:
host - The hostname of the SMTP server.

setFrom

public void setFrom(String from)
Sets the from address.

Parameters:
from - The address the email is from.

addMessage

public void addMessage(String msg)
Adds a message that is apppended in sequence to the message body.

Parameters:
msg - The message to append to the email.

addMessages

public void addMessages(String[] msg)
Adds an arrays of message strings to the message body.

Parameters:
msg - The array of messages.

addHeader

public void addHeader(String name,
                      String value)
Adds header parameters to a Map of headers.

Parameters:
name - The header name
value - The header value

addReplyTo

public void addReplyTo(String replyto)
Adds a reply-to addresses to the mail message.

Parameters:
replyto - The email address the recipient should reply to.

addBcc

public void addBcc(String bcc)
Adds an email address to the bcc field of the mail message

Parameters:
bcc - An email address to the bcc field of the mail message

addBCC

public void addBCC(String[] bcc)
Adds an array of bcc addresses to the mail message.

Parameters:
bcc - The array of email addresses to add to the BCC field.

addSignature

public void addSignature(String sig)
Adds a signature text for the message.

Parameters:
sig - The signature to add.

setSubject

public void setSubject(String subject)
Sets the subject text for the message.

Parameters:
subject - The subject field of the message.

addCc

public void addCc(String cc)
Add a CC address to the message.

Parameters:
cc - The CC address to add.

addCcs

public void addCcs(String[] ccs)
Add an array of CC address to the message.

Parameters:
ccs - the array of CC addresses to add.

addTo

public void addTo(String to)
Add a TO address to the message.

Parameters:
to - The to address to add.

addTos

public void addTos(String[] tos)
Adds an array of To addresses to the message.

Parameters:
tos - An array of email addresses to add to the TO field.

setDebug

public void setDebug(String debug)
Sets the debug mode

Parameters:
debug - The debug mode "true" or "nosend" mean isDebug is true.

addEncloseFile

public void addEncloseFile(String file)
Adds an enclosure file to the message

Parameters:
file - The file to add to the message.

addEncloseFiles

public void addEncloseFiles(String[] files)
Adds an array of enclosure files to the message.

Parameters:
files - the array of files to add.

addEncloseUri

public void addEncloseUri(String uri)
Adds an enclosure uri to the message.

Parameters:
uri - The enclosure uri.

addEncloseUris

public void addEncloseUris(String[] uris)
Adds an array of enclosure uris to the message.

Parameters:
uris - Array of uris. This method will trip any white space from the supplied uris.

setAuthentication

public void setAuthentication(String username,
                              String password)
sets the authentication username and password.

Parameters:
username - The username.
password - The clear text password.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.