Wiki per Email
Problem
Blogging with the iPhone, uploading pictures from the iPhone to foswiki is either extremely painful or just not possible at all.
Approach
Use Email. Send an email with photos to e.g.
myblog@mywikiserver.com and automatically the topic is created and pictures are attached.
A perl script processes incoming mails on STDIN and creates a blog posting topic
based on plain/text parts and creates attachments for all
image/jpeg parts. The blog topic name and the wiki user are identified by the 'From' part
of the mail header, the title is created based on the 'Subject'
part of the mail header.
Solution
Mail processing is done via an email alias in /etc/aliases to the apache/webserver user
(www-data). This ensures that file modifications are done with user
and group rights of the webserver. An Exim filter file
/var/www-data/.forward pipes the incoming mail to
/var/www/m2w/mail2wiki.pl that does the rest of the magic topic
handling.
The wiki user is identified by the 'From' header part and is translated to a valid wiki user by parsing .htpasswd.
The topic itself is composed of a number of .txt files created in
the ../temp directory:
- 00_titledata.txt contains topic meta data and the title
- msg-*.txt contains plain/text parts of the received email
- z0_metadata.txt contains img link and metadata for each image/jpeg
- z1_metadata.txt contains topic footer (sig and comment box)
Things to do:
- 'From' address can be spoofed. Some kind of gpg clear-signed input might be much better. However, that is currently not possible w/ the iPhone
- The location of .forward in /var/www is not optimal because it requires additional care in /etc/apache/conf.d/m2w.conf
Installation
(This is based on Debian Linux but can be adjusted to basically every other Linux flavour.)
- Download
mail2wiki.pl.txt
- Put it where your webserver can read and write, e.g.
/var/www/m2w/
- Add an alias in
/etc/aliases e.g. foswikimail: www-data so that mail sent to foswikimail@yourserver.com is being forwarded to the webserver user www-data. Don't forget to call newaliases
- Check
/etc/passwd whether www-data has a home directory (e.g. /var/www)
- Create
/var/www/.forward:
# Exim filter
pipe /var/www/m2w/mail2wiki.pl
- Make sure, everything belongs to the webserver user:
-
sudo chown www-data:www-data /var/www/.forward
-
sudo chown -R www-data:www-data /var/www/m2w
- Finally take a loot at
/var/www/m2w/mail2wiki.pl and adjust $installdir etc as required

This script has been tailored for my wiki. It is easy to modify though.
related stuff:
--
MatthiasWientapper - 10 Jul 2009