All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class nl.nmg.beans.MailBean

java.lang.Object
   |
   +----nl.nmg.beans.MailBean

public class MailBean
extends Object
implements Serializable
The MailBean is a simple bean to send email messages from JSP pages.

Using bean introspection and the fact that JSP pages may throw IOExceptions, usage can be very simple:

<BEAN name="mailer" type="nl.nmg.beans.MailBean"></BEAN>
<% mailer.send() %>

For more robust usage, the request parameter would be checked and nice error message written on an IOException.


Constructor Index

 o MailBean()
Allocates a new MailBean.

Method Index

 o getBody()
Returns the body of the message.
 o getCc()
Returns the additional recipients of the message.
 o getFrom()
Returns the sender of the message.
 o getServer()
Returns the SMTP server.
 o getSubject()
Returns the subject of the message.
 o getTo()
Returns the recipient of the message.
 o send()
Sends the email message.
 o setBody(String)
Sets the body of the message.
 o setCc(String)
Sets the additional recipients of the message.
 o setFrom(String)
Sets the sender of the message.
 o setServer(String)
Sets the SMTP server
 o setSubject(String)
Sets the subject of the message.
 o setTo(String)
Sets the recipient of the message.

Constructors

 o MailBean
 public MailBean()
Allocates a new MailBean. The following properties are set:

Methods

 o getServer
 public String getServer()
Returns the SMTP server.

Returns:
the SMTP server
 o setServer
 public void setServer(String server)
Sets the SMTP server

Parameters:
server - the SMTP server
 o getFrom
 public String getFrom()
Returns the sender of the message.

Returns:
the From: header value
 o setFrom
 public void setFrom(String from)
Sets the sender of the message. The sender email address can be specified in one of the following ways:

If from is null or empty, the sender is set to "unknown-sender@somewhere.com".

Parameters:
from - the email address of the sender
 o getTo
 public String getTo()
Returns the recipient of the message.

Returns:
the To: header value
 o setTo
 public void setTo(String to)
Sets the recipient of the message. The recipient email address can be specified in one of the following ways:

If to is null or empty, the sender is set to "unknown-recipient@somewhere.com".

Parameters:
the - email address of the recipient
 o getCc
 public String getCc()
Returns the additional recipients of the message.

Returns:
the Cc: header value
 o setCc
 public void setCc(String cc)
Sets the additional recipients of the message. The recipient email addresses are separated by comma's and may be specified in one of the following ways:

Parameters:
the - email addresses of the additional recipients
 o getSubject
 public String getSubject()
Returns the subject of the message.

Returns:
the Subject: header value
 o setSubject
 public void setSubject(String subject)
Sets the subject of the message.

If subject is null or empty, the subject is set to "<No subject specified>".

Parameters:
subject - the subject to set
 o getBody
 public String getBody()
Returns the body of the message.

Returns:
the body
 o setBody
 public void setBody(String body)
Sets the body of the message.

If body is null, the body is set to the empty string.

Parameters:
body - the body to set
 o send
 public void send() throws IOException
Sends the email message.

Throws: IOException
if there was an I/O or SMTP error

All Packages  Class Hierarchy  This Package  Previous  Next  Index