org.apache.turbine.util.mail
Class Email

java.lang.Object
  |
  +--org.apache.turbine.util.mail.Email
Direct Known Subclasses:
MultiPartEmail, SimpleEmail

public abstract class Email
extends java.lang.Object

The base class for all email messages. This class sets the sender's email & name, receiver's email & name, subject, and the sent date. Subclasses are responsible for setting the message body.

Version:
$Id: Email.java,v 1.2 2001/09/07 17:20:30 dlr Exp $
Author:
Jon S. Stevens, Frank Y. Kim, Brett McLaughlin, Greg Ritter, Regis Koenig

Field Summary
static java.lang.String ATTACHMENTS
           
private  java.util.Vector bccList
           
private  java.util.Vector ccList
           
protected  java.lang.String charset
          The charset to use for this message
static java.lang.String CONTENT_TYPE
           
static java.lang.String EMAIL_BODY
           
static java.lang.String EMAIL_SUBJECT
           
static java.lang.String FILE_SERVER
           
static java.lang.String ISO_8859_1
           
static java.lang.String KOI8_R
           
static java.lang.String MAIL_HOST
           
static java.lang.String MAIL_SERVER
           
static java.lang.String MAIL_SMTP_FROM
           
static java.lang.String MAIL_TRANSPORT_PROTOCOL
           
protected  javax.mail.internet.MimeMessage message
          The email message to send.
static java.lang.String RECEIVER_EMAIL
           
static java.lang.String RECEIVER_NAME
           
private  java.util.Vector replyList
           
static java.lang.String SENDER_EMAIL
          Constants used to Email classes.
static java.lang.String SENDER_NAME
           
static java.lang.String SMTP
           
static java.lang.String TEXT_HTML
           
static java.lang.String TEXT_PLAIN
           
private  java.util.Vector toList
          Lists of related email adresses
static java.lang.String US_ASCII
           
 
Constructor Summary
Email()
           
 
Method Summary
 Email addBcc(java.lang.String email, java.lang.String name)
          Add a blind BCC recipient to the email.
 Email addCc(java.lang.String email, java.lang.String name)
          Add a recipient CC to the email.
 Email addReplyTo(java.lang.String email, java.lang.String name)
          Add a reply to address to the email.
 Email addTo(java.lang.String email, java.lang.String name)
          Add a recipient TO to the email.
private  javax.mail.Session getMailSession()
          TODO: Document.
protected  void init()
          Initializes the mail.
protected  void initCriteria(Criteria criteria)
          Initialize the mail according to the Criteria.
protected  void initialize(Criteria criteria)
          Initializes the mail.
 void send()
          Does the work of actually sending the email.
 void setCharset(java.lang.String charset)
          Set the charset of the message.
 Email setFrom(java.lang.String email, java.lang.String name)
          Set the FROM field of the email.
abstract  Email setMsg(java.lang.String msg)
          Define the content of the mail.
 Email setSentDate(java.util.Date date)
          Set the sent date field.
 Email setSubject(java.lang.String subject)
          Set the email subject.
private  javax.mail.internet.InternetAddress[] toInternetAddressArray(java.util.Vector v)
          Utility to copy Vector of known InternetAddress objects into an array.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SENDER_EMAIL

public static final java.lang.String SENDER_EMAIL
Constants used to Email classes.

SENDER_NAME

public static final java.lang.String SENDER_NAME

RECEIVER_EMAIL

public static final java.lang.String RECEIVER_EMAIL

RECEIVER_NAME

public static final java.lang.String RECEIVER_NAME

EMAIL_SUBJECT

public static final java.lang.String EMAIL_SUBJECT

EMAIL_BODY

public static final java.lang.String EMAIL_BODY

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE

MAIL_SERVER

public static final java.lang.String MAIL_SERVER

MAIL_HOST

public static final java.lang.String MAIL_HOST

MAIL_SMTP_FROM

public static final java.lang.String MAIL_SMTP_FROM

MAIL_TRANSPORT_PROTOCOL

public static final java.lang.String MAIL_TRANSPORT_PROTOCOL

SMTP

public static final java.lang.String SMTP

TEXT_HTML

public static final java.lang.String TEXT_HTML

TEXT_PLAIN

public static final java.lang.String TEXT_PLAIN

ATTACHMENTS

public static final java.lang.String ATTACHMENTS

FILE_SERVER

public static final java.lang.String FILE_SERVER

KOI8_R

public static final java.lang.String KOI8_R

ISO_8859_1

public static final java.lang.String ISO_8859_1

US_ASCII

public static final java.lang.String US_ASCII

message

protected javax.mail.internet.MimeMessage message
The email message to send.

charset

protected java.lang.String charset
The charset to use for this message

toList

private java.util.Vector toList
Lists of related email adresses

ccList

private java.util.Vector ccList

bccList

private java.util.Vector bccList

replyList

private java.util.Vector replyList
Constructor Detail

Email

public Email()
Method Detail

setCharset

public void setCharset(java.lang.String charset)
Set the charset of the message.
Parameters:
charset - A String.
Returns:
An HtmlEmail.
Throws:
MessagingException. -  

getMailSession

private javax.mail.Session getMailSession()
TODO: Document.
Returns:
A Session.

initialize

protected void initialize(Criteria criteria)
                   throws javax.mail.MessagingException
Initializes the mail. Deprecated.
Parameters:
criteria - A Criteria.
Throws:
MessagingException. -  
See Also:
init.

init

protected void init()
             throws javax.mail.MessagingException
Initializes the mail.

This is the first method that should be called by a subclass in its constructor.

Throws:
MessagingException. -  

initCriteria

protected void initCriteria(Criteria criteria)
                     throws javax.mail.MessagingException
Initialize the mail according to the Criteria.

This method uses the criteria parameter to set the from, to and subject fields of the email. Deprecated; one should use the setFrom, addTo, etc. methods.

Parameters:
criteria - A Criteria.
Throws:
MessagingException. -  

setFrom

public Email setFrom(java.lang.String email,
                     java.lang.String name)
              throws javax.mail.MessagingException
Set the FROM field of the email.
Parameters:
email - A String.
name - A String.
Returns:
An Email.
Throws:
MessagingException. -  

addTo

public Email addTo(java.lang.String email,
                   java.lang.String name)
            throws javax.mail.MessagingException
Add a recipient TO to the email.
Parameters:
email - A String.
name - A String.
Returns:
An Email.
Throws:
MessagingException. -  

addCc

public Email addCc(java.lang.String email,
                   java.lang.String name)
            throws javax.mail.MessagingException
Add a recipient CC to the email.
Parameters:
email - A String.
name - A String.
Returns:
An Email.
Throws:
MessagingException. -  

addBcc

public Email addBcc(java.lang.String email,
                    java.lang.String name)
             throws javax.mail.MessagingException
Add a blind BCC recipient to the email.
Parameters:
email - A String.
name - A String.
Returns:
An Email.
Throws:
MessagingException. -  

addReplyTo

public Email addReplyTo(java.lang.String email,
                        java.lang.String name)
                 throws javax.mail.MessagingException
Add a reply to address to the email.
Parameters:
email - A String.
name - A String.
Returns:
An Email.
Throws:
MessagingException. -  

setSubject

public Email setSubject(java.lang.String subject)
                 throws javax.mail.MessagingException
Set the email subject.
Parameters:
subject - A String.
Returns:
An Email.
Throws:
MessagingException. -  

setSentDate

public Email setSentDate(java.util.Date date)
                  throws javax.mail.MessagingException
Set the sent date field.
Parameters:
date - A Date.
Returns:
An Email.
Throws:
MessagingException. -  

setMsg

public abstract Email setMsg(java.lang.String msg)
                      throws javax.mail.MessagingException
Define the content of the mail. It should be overidden by the subclasses.
Parameters:
msg - A String.
Returns:
An Email.
Throws:
MessagingException. -  

send

public void send()
          throws javax.mail.MessagingException
Does the work of actually sending the email.
Throws:
MessagingException, - if there was an error.

toInternetAddressArray

private javax.mail.internet.InternetAddress[] toInternetAddressArray(java.util.Vector v)
Utility to copy Vector of known InternetAddress objects into an array.
Parameters:
v - A Vector.
Returns:
An InternetAddress[].


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.