The IMAPGenerator is a new component included within the Mail block.

Simply put, it generates an XML listing of messages from an IMAP mailbox.

Setup

Get the JavaMail API jar from http://java.sun.com/products/javamail/, and the JAF activation.jar from http://java.sun.com/beans/glasgow/jaf.html. Put them in your WEB-INF/lib/ directory and restart your servlet container.

Next, include the following line in your sitemap.xmap:

<map:generator 
  label="content" 
  logger="sitemap.generator.imap" 
  name="imap" 
  src="org.apache.cocoon.generation.IMAPGenerator"/>

Usage

Now you should be good to go. The Generator is currently configured via parameters:

<map:match pattern="inbox">
  <map:generate type="imap">
    <map:parameter name="host" value="{request-param:host}"/>
    <map:parameter name="user" value="{request-param:user}"/>
    <map:parameter name="pass" value="{request-param:pass}"/>
  </map:generate>
  <map:serialize type="xml"/>
</map:match>

Sample Output

The generator currently generates XML using the "imap" prefix and the namespace URI of http://apache.org/cocoon/imap/1.0/.

<imap:imap xmlns:imap="http://apache.org/cocoon/imap/1.0/">
  <imap:messages>
    <imap:msg>
      <imap:subject>sample subject</imap:subject>
      <imap:from>tony collen &lt;foo@bar.org&gt;</imap:from>
      <imap:sentDate>Wed Sep 24 21:36:33 CDT 2003</imap:sentDate>
      <imap:num>1</imap:num>
    </imap:msg>
  </imap:messages>
</imap:imap>

Note

The IMAPGenerator (along with the entire Mail block) is considered unstable, and the contracts and APIs may change suddenly without warning, such as the output, or method of configuration.

IMAPGenerator (last edited 2009-09-20 23:41:07 by localhost)