User:Austin J. Che/Extensions/Wikilist

From OpenWetWare

Jump to: navigation, search

Usage

This extension allows any wiki page to be used as an email list. All links on a page of the form [[User:username]] (such as that formed by signing a page) are used as the members of the list. Duplicates are removed. Emails are sent to the user address stored in the wiki and only if emails are enabled from other users (under user preferences).

To send an email, you can go to the special page Special:Wikilist and enter the name of a page. A direct link to email members of a page is of the form [[Special:Wikilist/Pagename]]

In addition, the To address of the message is a real email address so that the email can be replied to by anyone using any email client (see technical details).

Technical Details

There are three files for installation:

  1. SpecialWikilist.php (creates the Special page on the wiki)
  2. wikilist.php (designed to be run from the command line and resends email to a list)
  3. wikilist.procmailrc (a procmail script whose main job is to call wikilist.php)

SpecialWikilist.php should be installed in the wiki extensions directory and require'd from LocalSettings.php. In addition, the variable $wgWikilistEmailHost must be set to the name of your email host name. It is probably easiest if the email host is the same physical machine as your wiki server unless your email server has access to the wiki database to look up the members of the list.

Your MTA must support plus addressing (where user+foo@domain is sent to user and the extra foo is ignored). Some mailers use '-' instead of '+' which is fine if you set $wgWikilistMailExtension to something other than the default of '+'. The other variable to be aware of is $wgWikilistEmailUser which is by default 'wikilist' and will be the user part of the email address. Some example setups that I've tried are:

  • Postfix: add to /etc/aliases wikilist: "|/path/to/procmail -m /path/to/wikilist.procmailrc $EXTENSION"
    • When mail comes for wikilist+extension@domain, postfix will automatically pass the extension to the procmail script using the variable $EXTENSION
  • Sendmail: local delivery should be set up to go through procmail. A user called wikilist should be created in /etc/passwd with some new home directory. Move the wikilist.procmailrc to this new directory, rename it .procmailrc, and set the right permissions. The easiest permissions are to set the owner of the directory and .procmailrc to root, make it world readable, and only user writable.

Some paths may need to be updated at the top of the wikilist.procmailrc and wikilist.php files (for example the path to php and sendmail). The procmailrc file will also likely need to be changed for your local system configuration. The example procmailrc file takes into account the virtual email host domain which you are unlikely to need. Also, make sure the user running procmail has read permissions on wikilist.php and LocalSettings.php (can be user wikilist, nobody, or something else depending on your setup).

The basic logic of mail delivery:

  • The internal wiki article ID uniquely identifies every page.
  • This ID allows us to create arbitrary list addresses of the form wikilist+ID@domain.
  • When someone goes to the Special page, a single email is sent to the list address above.
  • When a message is received by the mail server at the list address (either from someone's email client or from the Special page on the wiki), the mail is directed to user wikilist.
  • User (or alias) wikilist runs procmail with the list ID as the first argument.
  • The user's procmailrc passes the list ID to the wikilist.php script.
  • wikilist.php looks up the list ID and extracts the list recipients.
  • The message is resent via the local mailer to the list recipients.

Send bugs and comments to Austin Che. Other extensions including sources can be found at User:Austin J. Che/Extensions.

Personal tools