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
IOException
s, 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
.
-
MailBean()
- Allocates a new MailBean.
-
getBody()
- Returns the body of the message.
-
getCc()
- Returns the additional recipients of the message.
-
getFrom()
- Returns the sender of the message.
-
getServer()
- Returns the SMTP server.
-
getSubject()
- Returns the subject of the message.
-
getTo()
- Returns the recipient of the message.
-
send()
- Sends the email message.
-
setBody(String)
- Sets the body of the message.
-
setCc(String)
- Sets the additional recipients of the message.
-
setFrom(String)
- Sets the sender of the message.
-
setServer(String)
- Sets the SMTP server
-
setSubject(String)
- Sets the subject of the message.
-
setTo(String)
- Sets the recipient of the message.
MailBean
public MailBean()
- Allocates a new MailBean. The following properties are set:
- server:
"mail"
- from:
"unknown-sender@somewhere.com"
- to:
"unknown-recipient@somewhere.com"
- cc:
null
- subject:
"<No subject specified>"
- body:
""
getServer
public String getServer()
- Returns the SMTP server.
- Returns:
- the SMTP server
setServer
public void setServer(String server)
- Sets the SMTP server
- Parameters:
- server - the SMTP server
getFrom
public String getFrom()
- Returns the sender of the message.
- Returns:
- the
From:
header value
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:
- john@doe.com
- John Doe <john@doe.com>
- john@doe.com (John Doe)
If from
is null
or empty, the
sender is set to "unknown-sender@somewhere.com"
.
- Parameters:
- from - the email address of the sender
getTo
public String getTo()
- Returns the recipient of the message.
- Returns:
- the
To:
header value
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:
- john@doe.com
- John Doe <john@doe.com>
- john@doe.com (John Doe)
If to
is null
or empty, the
sender is set to "unknown-recipient@somewhere.com"
.
- Parameters:
- the - email address of the recipient
getCc
public String getCc()
- Returns the additional recipients of the message.
- Returns:
- the
Cc:
header value
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:
- john@doe.com
- John Doe <john@doe.com>
- john@doe.com (John Doe)
- Parameters:
- the - email addresses of the additional recipients
getSubject
public String getSubject()
- Returns the subject of the message.
- Returns:
- the
Subject:
header value
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
getBody
public String getBody()
- Returns the body of the message.
- Returns:
- the body
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
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