What is MailToPage feature?

Sometimes it may happen that a wiki is part of local network and users are not allowed to access it from outside the local network. In that case the user may want to edit any page urgently — this feature is then useful as this allows the user to get, set and find pages via email. This also checks whether the user asking for the operation has the necessary permission. If the user does not have permission then the operation won't be performed and the user is sent a "permission denied" mail.

How to use it?

There needs to be a separate E-Mail id for this purpose. A poller will continuously poll on this id and parses the request and replies accordingly. Request sent by user has to be in certain format for poller to be able to parse it. Subject of the mail should have this format. JSPWiki: $command $pageName/$Query. Please do not include anything else in the subject line.

Different Operations supported by this feature

Get Command

This command is used by user to get the page he wants. For that he needs to send a mail to a mail address assigned to JSPWiki with the get command and page name in the subject of the mail, in the format JSPWiki: get $PAGENAME.

Set command

Same as get command there is also a set command which allows user to change content of any page that he wants. For that he needs to send a mail to address assigned for this purpose and put newer content of the page in attachment with subject JSPWiki: set $PAGENAME.

Find Command

If user knows something about page or about the content of the page but doesn't know exactly what the page name is then he can use find command and can send a query in a mail with find command then he will get a mail in reply with the result of serach. For this he needs to send a mail to mail address assigned to this purpose with subject JSPWiki: find $QUERY. here query can be a word that you are looking for ot it can be combination of words or it can also be lucene query.

Authorization for these operations

User who does not have profile with JSPWiki cannot use this feature. Users having permission to view or edit can only get or set page respectively. If user does not have permission then user will receive error mail of permission denied. Same as that if any error occurs then user will be sent an error message in mail by poller.

How to embed it in your JSPWiki application

Download MailUpdater.java and Poller.java file. Create a package com.persistent.mailtopage and put both java files into it. open web.xml file and add servlet tag for mailtopage servlet.

  <servlet>
    <servlet-name>MailToPage</servlet-name>
    <servlet-class>com.persistent.mailtopage.MailToPage</servlet-class>
    <init-param>
      <param-name>host</param-name>
      <param-value>$MAILSERVER</param-value>
    </init-param>
    <init-param>
      <param-name>user</param-name>
      <param-value>$ACCOUNTFORJSPWIKI</param-value>
    </init-param>
    <init-param>
      <param-name>password</param-name>
      <param-value>$PASSWORD</param-value>
    </init-param>
    <init-param>
      <param-name>protocol</param-name>
      <param-value>$PROTOCOL</param-value>
    </init-param>
    <init-param>
      <param-name>propertiesFile</param-name>
      <param-value>/WEB-INF/jspwiki.properties</param-value>
    </init-param>
    <init-param>
      <param-name>timeInterval</param-name>
      <param-value>10000</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
  </servlet>

Parameters passed to servlet and their explaination:

Servlet name and servlet class is mapping to servlet class from web.xml file. Host is ip or domain name of mail server. like yahoo.com or persistent.co.in. User is the id created exclusively for this purpose. Password is of the id specified in User Parameter. PropertiesFile is location of jspwiki.properties file. TimeInterval is polling time interval after every succession of that time interval mail account will be polled for message.

How it works?

MailToPage servlet gets all the parameters it is passed from web.xml file and give it to Poller class which actually polls for messages and sends reply message. Poller class polls account specified and identifies command and sends appropriate reply.

Steps to set it up for your wiki application

Create a mail account exclusively for this purpose or use any account but in that case if your account will have any mail with subject containing jspwiki it might create a problem. Embed servlet tag for MailToPage servlet. create package com.persistent.mailtopage and put both MailToPage and Poller class in to that package. Please put jar files in the attachment in your classpath.

For any further query feel free to contact kiran_thakkar@persistent.co.in. Home page on jspwiki.org is http://www.jspwiki.org/wiki/KiranThakkar

Please give your feedbacks about this over here so that we can improve it.


Hi

Can you post compiled files for MailToPage.java and Poller.java?

Thanks

Bruce

--Bruce E Hayward, 20-Jun-2006


Hola, is it possible to have a plugin that just adds the text of an email and the attached files as attachments in a wiki-page with just the subject as title?

--Henrik Strindberg, 13-Dec-2006


Hi Henrik

Yes, it is very much possible. Plugin changes content of a page receiving a mail to change its content. Now we need to make plugin get a hook on module that adds Attachment to a page and supply content that we receive in a mail.

Let me know if you really need that functionality, I will change plugin and implement that.

--Kiran Thakkar, 12-Jan-2007


Hola,

Yes i really do, trying to get our little intranet to accept mail. I have also been trying to do the attachment parsing myself... with some success.

The problems I have been facing is:

  • Good formatting for wiki filename:
    • Suggestions: Subject + Sender + Date (encountered encoding issues)
  • Attachments:
    • Nested mails, get the "reply/forward/etc" stuff to work good (create new links)
    • Add images to the page (inline)

--Henrik Strindberg, 22-Mar-2007


Hi Henrik

I am quite busy these days. I will reply to your needs once i will get a bit free.

-Kiran Thakkar

--Kiran, 06-Apr-2007


No worries =)

--Henrik Strindberg, 24-May-2007

Add new attachment

In order to upload a new attachment to this page, please use the following box to find the file, then click on “Upload”.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
class
MailToPage.class 1.6 kB 1 01-Nov-2006 14:36 220.225.70.2
java
MailToPage.java 1.5 kB 1 25-Apr-2006 07:59 Kiran Thakkar
class
Poller$1.class 7.0 kB 1 01-Nov-2006 14:36 220.225.70.2
class
Poller.class 9.7 kB 1 01-Nov-2006 14:37 220.225.70.2
java
Poller.java 19.5 kB 2 25-Apr-2006 08:03 Kiran Thakkar
jar
activation.jar 54.7 kB 1 25-Apr-2006 08:11 Kiran Thakkar
jar
imap.jar 135.7 kB 1 25-Apr-2006 08:09 Kiran Thakkar
jar
mail.jar 347.4 kB 1 25-Apr-2006 08:10 Kiran Thakkar
« This page (revision-27) was last changed on 26-Sep-2007 23:24 by JanneJalkanen