Here's my approach to create a bridge between 2 interesting java applications. JspWiki and apache James
.
WikiMailet makes it possible to email to a wiki. Currently the mailet is in a very early stage, more proof-of-concept than actually useful. But it clearly shows the possibilities.
The current Mailet lets you mail to a special email address (configured in James), takes the subject as pagename and saves the body of the email in the wiki page.
Problems!!!#
- AFAIK the XMLRPC interface doesn't (yet) let me change or create pages. So I instantiated a WikiEngine instance in the Mailet and use that to enter data into the wiki. A possible solution would be to use Http post to the Edit.jsp itself, and enter data as a normal user would through the browser, but IMHO that looks ugly.
- The James mail server runs in a different VM as the WikiEngine web app. The Wiki cache doesn't know when a page is updated by email. So for the moment I simply turned off caching in my test setup. How should I solve this?
- Changes aren't included in the RSS feed AFAICS.
- Security: the only practical way to authenticate is through the senders email address. Obviously this isn't very secure ;-). But then again, the concept of a wiki makes it normally editable by everyone. A different approach would be to use SMTP authentication, but then you have to use that specific SMTP server to send to the wiki.
Current features!!!#
- Well, not much yet ;-)
- the email subject is used as page name.
- Formatting: Specify whether an email should replace or append an existing page. and add more info besides the body content: timestamp, from address.
- 0: The new text
- 1: The original text
- 2: The name of the sender
- 3: The subject (same as the pagename)
- 4: The current date.
Todo!!!#
- Enable HTML emails. Currently only plain text emails are handled correctly.
- Create new page. Currently only existing pages can be mailed to.
- process attachments (this is perhaps the most interesting feature. Many people know how to email attachments, fotos... but have difficulties with http file upload)
- Keep a history in a separate MailIndex page.
Configuration & setup!!!#
- First get Apache james and JspWiki running. The most practical setup is to have them both on the same machine. But, especially when you use JDBC storage this is not strictly required.
- Add all the necessary jar files (all jars from JspWiki/WEB-INF/lib) to james/apps/james/SAR-INF/lib
- add the Mailet jar (jamesWiki.jar) there as well.
- configure jspWiki:
- just turn of caching untill I found a solution.
- configure James (james/apps/james/SAR-INF/config.xml)
- add <mailetpackage>com.storedesk.jspwiki</mailetpackage> to the mailetpackages.
- Configure the mailet: use the needed Matching and specify a correct properties file.
Eg. if you want a specific emailaddress to be forwarded to the wiki:
<mailet match="RecipientIs=wiki@domain.com" class="WikiMailet">
<config>/projects/intranet/wiki/WEB-INF/jspwiki.properties</config>
<format>{4} / {2} \\\\{0}\r\n\r\n----\r\n\r\n{1}</format>
</mailet>
If both the wiki and mailserver are on the same machine, the config can simply point to the actual jspwiki.properties file.
Add new attachment
Only authorized users are allowed to upload new attachments.
List of attachments
| Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
|---|---|---|---|---|---|---|
java |
WikiMailet.java | 4.2 kB | 2 | 07-Jan-2005 11:53 | GeertVanDamme | |
jar |
jamesWiki.jar | 2.9 kB | 2 | 07-Jan-2005 11:53 | GeertVanDamme |