Search:

Apache » Lenya
project logo
  • Project
  • Developer
  • Community
  • Version 2.0
  • Version 1.2
  • Version 1.2
    • Installation
      • Download
      • Subversion Access
      • Install Instructions
    • Tutorial
      • Introduction
      • 1. Understanding Lenya
      • 2. Installing Lenya
      • 3. Anatomy of the Pipeline
      • 4. Editing in Lenya
      • 5. Custom Navigation in Lenya
      • 6a. Mod Proxy and Lenya
      • 6b. Mod Proxy and Lenya
    • How-To
      • FAQ
      • New Publication
      • Deploy Publication
      • Look and Feel
      • Custom Resource Type
      • Adding Mime Types
      • Site Navigation
      • LDAP Authentication
      • CMS Menus
      • CMS Screens
      • Search Publications
      • External Data
      • Unit Tests
    • Components
      • Access Control
        • Basic Terms
        • Access Controllers
        • Access Controller Resolvers
        • Authenticators
        • Authorizers
        • Policies and Policy Managers
        • Accreditable Managers
        • SSL Encryption
      • Authoring
        • Adding a new document creator
        • Image Upload
        • OpenOffice
      • Deployment
        • Proxying
      • Editors
        • HTML Form Editor
        • HTML One Form Editor
        • Bitflux Editor
        • Kupu
        • Xopus
      • Layout
        • Navigation
        • XHTML templating
        • Serving static resources
        • Lenya Menubar
      • Publication
        • PageEnvelopeModule
        • Site tree
      • Resource Types
        • Resource Types
      • Revision Control
        • Revision Controller
        • RCML
        • Check In
        • Check Out
        • Revisions
        • Rollback
      • Repository
        • WebDAV Servers
      • Search
        • Searching with Lucene
      • URI Handling
        • URI Parametrizer
        • URI Scheme
        • Usecases
      • Asset Management
        • Asset Management
      • Link Management
        • Link Management
      • Meta Data
        • Meta Data Handling
      • Multilingual Documents
        • Multilingual Document Handling
      • Tasks
        • The Task Concept
        • Defining Tasks
        • The TaskAction
        • Scheduling a Task
        • Included tasks
          • AntTask
          • DefaultFilePublisher
          • StaticHTMLExporter
          • MailTask
        • Developing Tasks
      • Workflow
        • Terms
        • The State Machine
        • Configuration
        • Implementation
      • Site Management
        • Archive
        • Copy
        • Deactivate
        • Delete
        • Delete the trash
        • Move
        • Move Up/Down
        • Rename
        • Restore
    • Miscellaneous
      • Namespaces
      • Reserved Names
      • XInclude Processor
    • 1.2 API (Javadoc)

Current Event

Built with Apache Lenya

The MailTask

Table of Contents
  • Task Parameters
    • Getting the mail data from an XML source
  • Declaring and Using the MailTask

A MailTask sends an e-mail. The parameters, such as recipient address, subject, and body, can either be provided as a task parameter or extracted from an XML document.

Task Parameters

The following parameters must be provided:

  • server : the SMTP server URI
  • from : you@yourhost.com
  • to : friend@mail.com
  • cc : other-friends@mail.com
  • subject : Hello World!
  • body : How are you?

Getting the mail data from an XML source

Additionally, you can pass a uri parameter to the MailTask:

  • uri : the URI to get the XML file from

If this parameter is present, the task tries to fetch an XML document from the URI. If the parameter uri starts with a http:// or ftp:// prefix, the absolute URI is used. If not, the URI is interpreted as relative to the local publication.

A complete XML document could look like this:


<mail:mail xmlns:mail="http://apache.org/cocoon/lenya/mail/1.0">
  <mail:server>mail.yourhost.com</mail:server>
  <mail:from>you@yourhost.com</mail:from>
  <mail:to>friend@mail.com</mail:to>
  <mail:cc>other-friends@mail.com</mail:cc>
  <mail:subject>Hello Friends!</mail:subject>
  <mail:body>How are you?</mail:body>
</mail:mail>

All child elements of <mail:mail> are optional. If the uri task parameter is provided, the XML document is fetched from the URI and the parameters are extracted.

Task parameters have a higher priority than elements of the document. This makes it possible to access one complete XML file from different MailTasks and override the recepient address or other values.

Declaring and Using the MailTask

In tasks.xconf, a typical mail task looks like follows:


  <task id="send-newsletter" class="org.lenya.cms.mail.MailTask">
    <label>Send Newsletter</label>
    <parameter name="server" value="mail.example.com"/>
    <parameter name="from" value="info@example.com"/>
    <parameter name="to" value="newsletter-subscribers@example.com"/>
    <parameter name="uri" value="/authoring/newsletter/mail.xml"/>
  </task>

The actual newsletter is received from the URI that is interpreted relativly to the publication URI. The task can be invoked in a sitemap pipeline:


  <map:action name="task" src="org.lenya.cms.cocoon.acting.TaskAction"/>
  
  ...
  
  <map:match pattern="newsletter/send">
    <map:act type="task">
      <map:parameter name="task-id" value="send-newsletter"/>
      <map:redirect-to uri="report-success.html" session="true"/>
    </map:act>
    <map:redirect-to uri="report-failure.html" session="true"/>
  </map:match>

Copyright © 1999-2011 The Apache Software Foundation. All rights reserved.

Apache Lenya, Apache, and the Apache feather logo are trademarks of The Apache Software Foundation.