Extension:EmailToWiki

Installation
Download the following source files, and save them into a directory called EmailToWiki in your wiki's extensions directory. This extension depends on the SimpleForms extension so that must be downloaded and installed too, see Extension:Simple Forms for details. Include the PHP script from your LocalSettings.php file like usual:
 * OrganicDesign:Extension:EmailToWiki.php
 * EmailToWiki.pl

The EmailToWiki extension is not a MediaWiki extension in the usual sense because it's written in Perl not PHP. When it is executed it checks the specified POP box, and scans the messages for any messages requiring article adjustments. It only checks once then exits, so it must be executed periodically from your system scheduler.

If using a Windows server you can get Perl from www.activeperl.org and add the execution to you system scheduler from control panel. On Linux you'll already have Perl and you can add the script to your crontab with a line similar to the following which calls the script once every 5 minutes. */5 * * * * /var/www/wiki/extensions/EmailToWiki/EmailToWiki.pl myConfigFile

Email addresses
The username part of the email address (everything before the @) is treated as a page title, and the content of the email is appended to the content of the article having that title, or to a newly created article of that name if one didn't already exist.

Many characters which are allowed in article titles are not allowed in email addresses, so the title gets URL-encoded first which converts any illegal characters to a percentage followed by their numeric code. But also the percentages are one of the invalid email characters, so the encoding uses the ampersand character instead. The main reason this is of any concern is that any emails directed at pages outside the default namespace (like a talk page) include a colon character which is one of the invalid ones and will be converted to &3A, for example: [mailto:User_talk&3ANad@foo.bar User_talk&3ANad@foo.bar].

The extension also adds a MediaWiki variable called which expands to an email link for the current page.

Configuration
The configuration files must reside in the same directory as the other two scripts. There can be any number of them to cater for having many wikis on the same server needing to be emailed. Each has its own config file and cron entry. The config file's name should be the wiki name followed by .conf. The log file will automatically be named the same but with the .conf extension replaced with .log.

The EmailToWiki.pl script takes a single parameter which is the name of a configuration file which must reside in the same directory as the script. The configuration file sets some global variables to specify configuration, the different variables are as follows:

Todo & bugs

 * Currently only first address in TO field is extracted
 * Testing for failed HTTP request not working
 * Allow an option for filters to use MW registered users with emails