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.4 2002/07/11 16:53:20 mpoeschl Exp $
Author:
Jon S. Stevens, Frank Y. Kim, Brett McLaughlin, Greg Ritter, Regis Koenig

Field Summary
static java.lang.String ATTACHMENTS
           
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
           
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
           
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.
protected  void init()
          Initializes the mail.
protected  void initCriteria(org.apache.torque.util.Criteria criteria)
          Initialize the mail according to the Criteria.
protected  void initialize(org.apache.torque.util.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SENDER_EMAIL

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

See Also:
Constant Field Values

SENDER_NAME

public static final java.lang.String SENDER_NAME
See Also:
Constant Field Values

RECEIVER_EMAIL

public static final java.lang.String RECEIVER_EMAIL
See Also:
Constant Field Values

RECEIVER_NAME

public static final java.lang.String RECEIVER_NAME
See Also:
Constant Field Values

EMAIL_SUBJECT

public static final java.lang.String EMAIL_SUBJECT
See Also:
Constant Field Values

EMAIL_BODY

public static final java.lang.String EMAIL_BODY
See Also:
Constant Field Values

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE
See Also:
Constant Field Values

MAIL_SERVER

public static final java.lang.String MAIL_SERVER
See Also:
Constant Field Values

MAIL_HOST

public static final java.lang.String MAIL_HOST
See Also:
Constant Field Values

MAIL_SMTP_FROM

public static final java.lang.String MAIL_SMTP_FROM
See Also:
Constant Field Values

MAIL_TRANSPORT_PROTOCOL

public static final java.lang.String MAIL_TRANSPORT_PROTOCOL
See Also:
Constant Field Values

SMTP

public static final java.lang.String SMTP
See Also:
Constant Field Values

TEXT_HTML

public static final java.lang.String TEXT_HTML
See Also:
Constant Field Values

TEXT_PLAIN

public static final java.lang.String TEXT_PLAIN
See Also:
Constant Field Values

ATTACHMENTS

public static final java.lang.String ATTACHMENTS
See Also:
Constant Field Values

FILE_SERVER

public static final java.lang.String FILE_SERVER
See Also:
Constant Field Values

KOI8_R

public static final java.lang.String KOI8_R
See Also:
Constant Field Values

ISO_8859_1

public static final java.lang.String ISO_8859_1
See Also:
Constant Field Values

US_ASCII

public static final java.lang.String US_ASCII
See Also:
Constant Field Values

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

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.

initialize

protected void initialize(org.apache.torque.util.Criteria criteria)
                   throws javax.mail.MessagingException
Initializes the mail. Deprecated.

Parameters:
criteria - A Criteria.
Throws:
MessagingException.
javax.mail.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.
javax.mail.MessagingException

initCriteria

protected void initCriteria(org.apache.torque.util.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.
javax.mail.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.
javax.mail.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.
javax.mail.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.
javax.mail.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.
javax.mail.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.
javax.mail.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.
javax.mail.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.
javax.mail.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.
javax.mail.MessagingException

send

public void send()
          throws javax.mail.MessagingException
Does the work of actually sending the email.

Throws:
MessagingException, - if there was an error.
javax.mail.MessagingException


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