org.apache.turbine.util.mail
Class MailMessage

java.lang.Object
  extended byorg.apache.turbine.util.mail.MailMessage

Deprecated. Use org.apache.commons.mail.MailMessage instead.

public class MailMessage
extends java.lang.Object

Creates a very simple text/plain message and sends it.

MailMessage creates a very simple text/plain message and sends it. It can be used like this:

 MailMessage sm = new MailMessage("mail.domain.net",
                                  "toYou@domain.net",
                                  "fromMe@domain",
                                  "this is the subject",
                                  "this is the body");
 
Another example is:
 MailMessage sm = new MailMessage();
 sm.setHost("mail.domain.net");
 sm.setHeaders("X-Mailer: Sendmail class, X-Priority: 1(Highest)");
 sm.setFrom("Net Freak1 user1@domain.com");
 sm.setReplyTo("Net Freak8 user8@domain.com");
 sm.setTo("Net Freak2 user2@domain.com, Net Freak3 user3@domain.com");
 sm.setCc("Net Freak4 user4@domain.com, Net Freak5 user5@domain.com");
 sm.setBcc("Net Freak6 user6@domain.com, Net Freak7 user7@domain.com");
 sm.setSubject("New Sendmail Test");
 sm.setBody("Test message from Sendmail class, more features to be added.
             Like multipart messages, html, binary files...");
 sm.setDebug(true);
 sm.send();
 

Version:
$Id: MailMessage.java 264148 2005-08-29 14:21:04Z henning $
Author:
David Duddleston

Field Summary
protected  javax.mail.internet.InternetAddress[] bcc
          Deprecated. The email address or addresses that the email is being blind-carbon-copied to.
protected  java.lang.String body
          Deprecated. The body of the email message.
protected  javax.mail.internet.InternetAddress[] cc
          Deprecated. The email address or addresses that the email is being carbon-copied to.
protected  boolean debug
          Deprecated. Displays debug information when true.
protected  javax.mail.internet.InternetAddress from
          Deprecated. The email address that the mail is being sent from.
protected  java.util.Hashtable headers
          Deprecated. Used to specify the mail headers.
protected  java.lang.String host
          Deprecated. The host name of the mail server to use.
protected  javax.mail.internet.InternetAddress[] replyTo
          Deprecated. The email address used for replies to this message.
protected  java.lang.String subject
          Deprecated. The subject of the email message.
protected  javax.mail.internet.InternetAddress[] to
          Deprecated. The email address or addresses that the email is being sent to.
 
Constructor Summary
MailMessage()
          Deprecated. Default constructor.
MailMessage(java.lang.String h, java.lang.String t, java.lang.String f, java.lang.String s, java.lang.String b)
          Deprecated. Constructor used to specify host, to, from, subject, and body.
MailMessage(java.lang.String h, java.lang.String t, java.lang.String c, java.lang.String bc, java.lang.String f, java.lang.String s, java.lang.String b, boolean d)
          Deprecated. Constructor used to specify host, to, cc, bcc, from, subject, body, and debug.
 
Method Summary
 void addHeader(java.lang.String name, java.lang.String value)
          Deprecated. Adds a header (name, value) to the headers Hashtable.
static javax.mail.internet.InternetAddress[] parseAddressField(java.lang.String str)
          Deprecated. Parse an address field.
static javax.mail.internet.InternetAddress[] parseAddressList(java.lang.String[] aList)
          Deprecated. Parse an address list.
static void parseHeader(java.lang.String str, java.util.Hashtable headers)
          Deprecated. Parse a header.
static java.util.Hashtable parseHeaderField(java.lang.String str)
          Deprecated. Parse a header field.
static java.util.Hashtable parseHeaderList(java.lang.String[] hList)
          Deprecated. Parse a header list.
static javax.mail.internet.InternetAddress parseInternetAddress(java.lang.String str)
          Deprecated. Parse an Internet address.
static javax.mail.internet.InternetAddress parseInternetAddress(java.lang.String address, java.lang.String personal)
          Deprecated. Parse an Internet address.
 boolean send()
          Deprecated. Send the message.
 void setBcc(javax.mail.internet.InternetAddress[] bc)
          Deprecated. Used to specify the email address that the mail is being blind-carbon-copied to.
 void setBcc(java.lang.String bc)
          Deprecated. Used to specify the email address that the mail is being blind-carbon-copied to.
 void setBody(java.lang.String b)
          Deprecated. Used to specify the body of the email message.
 void setCc(javax.mail.internet.InternetAddress[] c)
          Deprecated. Used to specify the email address that the mail is being sent to.
 void setCc(java.lang.String c)
          Deprecated. Used to specify the email address that the mail is being carbon-copied to.
 void setDebug(boolean d)
          Deprecated. Setting to true will enable the display of debug information.
 void setDebug(java.lang.String str)
          Deprecated. Setting to true will enable the display of debug information.
 void setFrom(javax.mail.internet.InternetAddress f)
          Deprecated. Used to specify the email address that the mail is being sent from.
 void setFrom(java.lang.String f)
          Deprecated. Used to specify the email address that the mail is being sent from.
 void setHeaders(java.util.Hashtable h)
          Deprecated. Used to specify the mail headers.
 void setHeaders(java.lang.String h)
          Deprecated. Used to specify the mail headers.
 void setHost(java.lang.String h)
          Deprecated. Used to specify the mail server host.
 void setReplyTo(javax.mail.internet.InternetAddress[] rt)
          Deprecated. Used to specify the email address that the mail is being sent from.
 void setReplyTo(java.lang.String rp)
          Deprecated. Used to specify the email address that the mail is being sent from.
 void setSubject(java.lang.String s)
          Deprecated. Used to specify the subject of the email message.
 void setTo(javax.mail.internet.InternetAddress[] t)
          Deprecated. Used to specify the email address that the mail is being sent to.
 void setTo(java.lang.String t)
          Deprecated. Used to specify the email address that the mail is being sent to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

protected java.lang.String host
Deprecated. 
The host name of the mail server to use.


headers

protected java.util.Hashtable headers
Deprecated. 
Used to specify the mail headers. Example: X-Mailer: Sendmail, X-Priority: 1(highest) or 2(high) 3(normal) 4(low) and 5(lowest) Disposition-Notification-To: returnR user@domain.net


from

protected javax.mail.internet.InternetAddress from
Deprecated. 
The email address that the mail is being sent from.


replyTo

protected javax.mail.internet.InternetAddress[] replyTo
Deprecated. 
The email address used for replies to this message.


to

protected javax.mail.internet.InternetAddress[] to
Deprecated. 
The email address or addresses that the email is being sent to.


cc

protected javax.mail.internet.InternetAddress[] cc
Deprecated. 
The email address or addresses that the email is being carbon-copied to.


bcc

protected javax.mail.internet.InternetAddress[] bcc
Deprecated. 
The email address or addresses that the email is being blind-carbon-copied to.


subject

protected java.lang.String subject
Deprecated. 
The subject of the email message.


body

protected java.lang.String body
Deprecated. 
The body of the email message.


debug

protected boolean debug
Deprecated. 
Displays debug information when true.

Constructor Detail

MailMessage

public MailMessage()
Deprecated. 
Default constructor. Must use the setHost, setTo, and other set functions to properly send an email. host, to, cc, bcc, and from are set to null. subject, and body are set to empty strings. debug is set to false.


MailMessage

public MailMessage(java.lang.String h,
                   java.lang.String t,
                   java.lang.String f,
                   java.lang.String s,
                   java.lang.String b)
Deprecated. 
Constructor used to specify host, to, from, subject, and body.

Parameters:
h - A String with the host.
t - A String with the TO.
f - A String with the FROM.
s - A String with the SUBJECT.
b - A String with the BODY.

MailMessage

public MailMessage(java.lang.String h,
                   java.lang.String t,
                   java.lang.String c,
                   java.lang.String bc,
                   java.lang.String f,
                   java.lang.String s,
                   java.lang.String b,
                   boolean d)
Deprecated. 
Constructor used to specify host, to, cc, bcc, from, subject, body, and debug.

Parameters:
h - A String with the host.
t - A String with the TO.
c - A String with the CC.
bc - A String with the BCC.
f - A String with the FROM.
s - A String with the SUBJECT.
b - A String with the BODY.
d - True if debugging is wanted.
Method Detail

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Deprecated. 
Adds a header (name, value) to the headers Hashtable.

Parameters:
name - A String with the name.
value - A String with the value.

parseAddressField

public static javax.mail.internet.InternetAddress[] parseAddressField(java.lang.String str)
Deprecated. 
Parse an address field.

Parameters:
str - A String with the address.
Returns:
An InternetAddress[].

parseAddressList

public static javax.mail.internet.InternetAddress[] parseAddressList(java.lang.String[] aList)
Deprecated. 
Parse an address list.

Parameters:
aList - A String[] with the addresses.
Returns:
An InternetAddress[].

parseHeader

public static void parseHeader(java.lang.String str,
                               java.util.Hashtable headers)
Deprecated. 
Parse a header.

Parameters:
str - A String with the header.
headers - A Hashtable with the current headers.

parseHeaderField

public static java.util.Hashtable parseHeaderField(java.lang.String str)
Deprecated. 
Parse a header field.

Parameters:
str - A String with the header field.
Returns:
A Hashtable with the parsed headers.

parseHeaderList

public static java.util.Hashtable parseHeaderList(java.lang.String[] hList)
Deprecated. 
Parse a header list.

Parameters:
hList - A String[] with the headers.
Returns:
A Hashtable with the parsed headers.

parseInternetAddress

public static javax.mail.internet.InternetAddress parseInternetAddress(java.lang.String str)
Deprecated. 
Parse an Internet address.

Parameters:
str - A String with the address.
Returns:
An InternetAddress.

parseInternetAddress

public static javax.mail.internet.InternetAddress parseInternetAddress(java.lang.String address,
                                                                       java.lang.String personal)
Deprecated. 
Parse an Internet address.

Parameters:
address - A String with the address.
personal - A String.
Returns:
An InternetAddress.

send

public boolean send()
Deprecated. 
Send the message. The to, from, subject, host, and body should be set prior to using this method.

Returns:
True is message was sent.

setBcc

public void setBcc(javax.mail.internet.InternetAddress[] bc)
Deprecated. 
Used to specify the email address that the mail is being blind-carbon-copied to.

Parameters:
bc - An InternetAddress[].

setBcc

public void setBcc(java.lang.String bc)
Deprecated. 
Used to specify the email address that the mail is being blind-carbon-copied to.

Parameters:
bc - A String.

setBody

public void setBody(java.lang.String b)
Deprecated. 
Used to specify the body of the email message.

Parameters:
b - A String.

setCc

public void setCc(javax.mail.internet.InternetAddress[] c)
Deprecated. 
Used to specify the email address that the mail is being sent to.

Parameters:
c - An InternetAddress[].

setCc

public void setCc(java.lang.String c)
Deprecated. 
Used to specify the email address that the mail is being carbon-copied to.

Parameters:
c - A String.

setDebug

public void setDebug(java.lang.String str)
Deprecated. 
Setting to true will enable the display of debug information.

Parameters:
str - A String.

setDebug

public void setDebug(boolean d)
Deprecated. 
Setting to true will enable the display of debug information.

Parameters:
d - A boolean.

setFrom

public void setFrom(java.lang.String f)
Deprecated. 
Used to specify the email address that the mail is being sent from.

Parameters:
f - A String.

setFrom

public void setFrom(javax.mail.internet.InternetAddress f)
Deprecated. 
Used to specify the email address that the mail is being sent from.

Parameters:
f - An InternetAddress.

setHeaders

public void setHeaders(java.lang.String h)
Deprecated. 
Used to specify the mail headers. Example: X-Mailer: Sendmail, X-Priority: 1(highest) or 2(high) 3(normal) 4(low) and 5(lowest) Disposition-Notification-To: returnR user@domain.net

Parameters:
h - A String.

setHeaders

public void setHeaders(java.util.Hashtable h)
Deprecated. 
Used to specify the mail headers. Example: X-Mailer: Sendmail, X-Priority: 1(highest) or 2(high) 3(normal) 4(low) and 5(lowest) Disposition-Notification-To: returnR user@domain.net

Parameters:
h - A Hashtable.

setHost

public void setHost(java.lang.String h)
Deprecated. 
Used to specify the mail server host.

Parameters:
h - A String.

setReplyTo

public void setReplyTo(javax.mail.internet.InternetAddress[] rt)
Deprecated. 
Used to specify the email address that the mail is being sent from.

Parameters:
rt - An InternetAddress[].

setReplyTo

public void setReplyTo(java.lang.String rp)
Deprecated. 
Used to specify the email address that the mail is being sent from.

Parameters:
rp - A String.

setSubject

public void setSubject(java.lang.String s)
Deprecated. 
Used to specify the subject of the email message.

Parameters:
s - A String.

setTo

public void setTo(javax.mail.internet.InternetAddress[] t)
Deprecated. 
Used to specify the email address that the mail is being sent to.

Parameters:
t - An InternetAddress[].

setTo

public void setTo(java.lang.String t)
Deprecated. 
Used to specify the email address that the mail is being sent to.

Parameters:
t - A String.


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