|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsunlabs.brazil.template.Template
sunlabs.brazil.handler.SMTPHandler (view source)
public class SMTPHandler
Handler (or template) for Sending an email message via SMTP. The following server properties are used:
MatchString
).
<param>
tags (see below).
[prefix].error
will contain the
error message.
There are 2 ways of using the sendmail
template:
param
tag adds an additional header
to the email message. There may be multiple headers of the same
name
, and their order is preserved.
When a singleton tag is used,
the To:
header is filled in to match the actual
recipients.
If you need to specify cc
, bcc
, or other
mail headers use param
tags.
Note:
The to
attribute, which is required,
specifies the actual recipients. When to
is specified
as part of a param
tag, it is the recipient list presented
to the email recipient, which may have nothing to do wih the actual
recipients. In the singleton case, they are made the same.
Query parameters:
Field Summary |
---|
Fields inherited from class sunlabs.brazil.template.Template |
---|
debug |
Constructor Summary | |
---|---|
SMTPHandler()
|
Method Summary | |
---|---|
boolean |
done(RewriteContext hr)
If we run off the end of the page, but there is email pending to be sent, send it anyway. |
boolean |
init(RewriteContext hr)
Called before this template processes any tags. |
boolean |
init(Server server,
String prefix)
Initializes the handler. |
boolean |
respond(Request request)
Responds to an HTTP request. |
static void |
smtp(String fromHost,
String smtpHost,
String from,
String to,
String body,
StringMap headers)
Send an email message via smtp - simple version. |
static void |
smtp(String fromHost,
String smtpHost,
String from,
String to,
String body,
StringMap headers,
Server server)
|
void |
tag_param(RewriteContext hr)
Add an additional email header. |
void |
tag_sendmail(RewriteContext hr)
set-up an email message for sending. |
void |
tag_slash_sendmail(RewriteContext hr)
If we haven't sent the mail yet - send it. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SMTPHandler()
Method Detail |
---|
public boolean init(Server server, String prefix)
Handler
init
in interface Handler
server
- The HTTP server that created this Handler
.
Typical Handler
s will use Server.props
to obtain run-time configuration information.prefix
- The handlers name.
The string this Handler
may prepend to all
of the keys that it uses to extract configuration information
from Server.props
. This is set (by the Server
and ChainHandler
) to help avoid configuration parameter
namespace collisions.
true
if this Handler
initialized
successfully, false
otherwise. If
false
is returned, this Handler
should not be used.public boolean respond(Request request) throws IOException
Handler
respond
in interface Handler
request
- The Request
object that represents the HTTP
request.
true
if the request was handled. A request was
handled if a response was supplied to the client, typically
by calling Request.sendResponse()
or
Request.sendError
.
IOException
- if there was an I/O error while sending the response to
the client. Typically, in that case, the Server
will (try to) send an error message to the client and then
close the client's connection.
The IOException
should not be used to silently
ignore problems such as being unable to access some
server-side resource (for example getting a
FileNotFoundException
due to not being able
to open a file). In that case, the Handler
's
duty is to turn that IOException
into a
HTTP response indicating, in this case, that a file could
not be found.
public boolean init(RewriteContext hr)
Template
init
in interface TemplateInterface
init
in class Template
public void tag_sendmail(RewriteContext hr)
public void tag_slash_sendmail(RewriteContext hr)
public boolean done(RewriteContext hr)
done
in interface TemplateInterface
done
in class Template
public void tag_param(RewriteContext hr)
look for: <param name="..." value="...>.
Which will add the email header: name: value
.
The name "body" is special, and will cause the email body to be replaced.
public static void smtp(String fromHost, String smtpHost, String from, String to, String body, StringMap headers) throws IOException
fromHost
- the hostname of the sender (may be null)smtpHost
- the SMTP host (whose smtp daemon to contact)from
- who the email is fromto
- a space delimited list of recepientsbody
- The message bodyheaders
- message headers (may be null)
IOException,
- if any errors occured (yuk)
Either the headers Or body may be null, but not both.
IOException
public static void smtp(String fromHost, String smtpHost, String from, String to, String body, StringMap headers, Server server) throws IOException
IOException
|
Version Kenai-svn-r24, Generated 08/18/09 Copyright (c) 2001-2009, Sun Microsystems. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |