org.apache.cocoon.acting
Class Sendmail

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.acting.AbstractAction
          extended by org.apache.cocoon.acting.ServiceableAction
              extended by org.apache.cocoon.acting.Sendmail
All Implemented Interfaces:
Component, Configurable, LogEnabled, Serviceable, ThreadSafe, Action
Direct Known Subclasses:
SendmailAction

public class Sendmail
extends ServiceableAction
implements ThreadSafe, Configurable

The Sendmail action class sends email. Action supports following parameters:

smtp-host
The smtp server to send the mail through. If not specified, default from cocoon.xconf will be used.
smtp-user
The smtp user. If smtp-user and smtp-host not specified, default from cocoon.xconf will be used.
smtp-password
The smtp user's password. If smtp-user and smtp-host not specified, default from cocoon.xconf will be used.
from
the email address the mail appears to be from
to
the email address(es) the mail it sent to. This can be multiple addresses separated with commas.
replyTo
the email address(es) replies should be sent to. This can be multiple addresses separated with commas.
cc
an email address(es) of someone, who should receive a carbon copy. This can also be a list of multiple addresses separated by commas.
bcc
an email address(es) of someone, who should receive a black carbon copy. This can also be a list of multiple addresses separated by commas.
subject
the subject line of the email
src
A url specifying the source of the text body of the email
srcMimeType
The optional Mime Type of the source of the text body of the email if you specified src
body
the text body of the email, if src is specified, body will be ignored
charset
the character set, which should be used the encode the body text. This parameter is only used, if no attachements are send.
attachments
One or more attachments, separated by whitespace, which should be attached to the email message. If the argument contains a ':', it is assumed, that the argument describes a org.apache.excalibur.source.Source object. Otherwise, it is assumed, that the argument describes a request parameter of an uploaded file, which Cocoon has internally turned into a Part object.

Minimally, from, to, body parameters should be specified. Rest of parameters are optional.

The class loads all of these parameters from the sitemap, except the attachements, which may come from file upload request parameters. Note it's strongly recommended that the to, cc and bcc addresses be specified by the sitemap, not the request, to prevent possible abuse of the SendmailAction as a spam source.

One or two parameters are returned to the sitemap depending on the outcome of sending the message: status and message.

If the email message could be successfully delivered only the parameter status with the value success is returned.

If there was a problem sending the message, status can have the value user-error and the message parameter is set to an explainatory text. This usually indicates problems with one or more email addresses. Other problems lead to a value of server-error for status and message contains a corresponding message.

Since:
2.1
Version:
CVS $Id: Sendmail.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Frank Ridderbusch, Christian Haul, Donald Ball, Andrzej Taramina

Field Summary
static String REQUEST_ATTRIBUTE
          Request-Attribute that holds status data
 
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
 
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
 
Fields inherited from interface org.apache.cocoon.acting.Action
ROLE
 
Constructor Summary
Sendmail()
           
 
Method Summary
 Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters)
          Controls the processing against some values of the Dictionary objectModel and returns a Map object with values used in subsequent sitemap substitution patterns.
 void configure(Configuration conf)
           
 
Methods inherited from class org.apache.cocoon.acting.ServiceableAction
service
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_ATTRIBUTE

public static final String REQUEST_ATTRIBUTE
Request-Attribute that holds status data

See Also:
Constant Field Values
Constructor Detail

Sendmail

public Sendmail()
Method Detail

configure

public void configure(Configuration conf)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException

act

public Map act(Redirector redirector,
               SourceResolver resolver,
               Map objectModel,
               String source,
               Parameters parameters)
        throws Exception
Description copied from interface: Action
Controls the processing against some values of the Dictionary objectModel and returns a Map object with values used in subsequent sitemap substitution patterns. NOTE: This interface is designed so that implentations can be ThreadSafe. When an action is ThreadSafe, only one instance serves all requests : this reduces memory usage and avoids pooling.

Specified by:
act in interface Action
resolver - The SourceResolver in charge
objectModel - The Map with object of the calling environment which can be used to select values this controller may need (ie Request, Response).
source - A source String to the Action
parameters - The Parameters for this invocation
Returns:
Map The returned Map object with sitemap substitution values which can be used in subsequent elements attributes like src= using a xpath like expression: src="mydir/{myval}/foo" If the return value is null the processing inside the element of the sitemap will be skipped.
Throws:
Exception - Indicates something is totally wrong


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.