A board game designer's web site

 Copyright Eric Pietrocupo


E-Mail: ericp[AT]lariennalibrary.com


General Information

My Designs

Game Design Knowledge

My Board Games

MailPosts

Page: PmWiki.MailPosts - Last Modified : Tue, 11 Jul 06 - 905 Visits

administrators (basic) << | PmWiki.Variables | >>

As of PmWiki 2.1.7, the MailPosts capability is being superceded by the more advanced notify.php script. See Notify for details.

The mail1318posts.php script allows a site administrator to configure PmWiki to send email1318 messages whenever pages are changed on the wiki site. MailPosts can be configured so that multiple page changes over a short period of time are combined into a single email1318 message (to avoid flooding a mail1318box).

The MailPosts feature is especially useful for sites that have infrequent updates, eliminating the need to frequently check RecentChanges pages just to see if anything has changed.

Full configuration details are available in scripts/mail1318posts.php.

Below is a brief synopsis of what needs to go in config.php or a per-group customization script for MailPosts:

 <?php if (!defined('PmWiki')) exit();
 $EnableMailPosts=1;                   # to enable mail1318posts
 $MailPostsTo="somebody@example.com";  # where to send mail1318 
 $MailPostsDelay=1800;                 # wait 30+ min after initial post
 $MailPostsSquelch=7200;               # require 2+ hours between mail1318s

Note that $MailPostsTo may be a comma-separated list of addresses if multiple recipients are desired.

For newbies: The ONLY file that needs editing is the local/config.php for this recipe to work. Add any or all of the configurations to the config.php file and it should work rather easily, assuming your host meets the other requirements.

On a per group basis you could set local/MyGroup.php (Create the MyGroup.php file if necessary) to:

 <?php if (!defined('PmWiki')) exit();
 $EnableMailPosts=1;                           # Enable mail1318posts
 $MailPostsTo="xxx@mail13181.com, yyy@mail13182.com";  # where to send mail1318
 $MailPostsFrom="bbb@mail13184.com";
 $MailPostsDelay=1800;            # Wait 30+ minutes after initial post
 $MailPostsSquelch=7200;          # Require 2+ hours between mail1318s@]
 $pagename = ResolvePageName($pagename);
 $group = PageVar($pagename, '$Group');
 $MailPostsMessage = "Recent wiki posts:\n"
    ."  ($ScriptUrl/$group/RecentChanges)\n\n\$MailPostsList\n";
 $MailPostsFile = "$WorkDir/.$group.mail1318posts";

Now make a change or add a document to one of the MyGroup documents and save it. You should receive an email1318. Be patient. Even if you set (my test settings)

 $MailPostsDelay=18;              # Wait 18 seconds after initial post
 $MailPostsSquelch=72;            # Wait 72 seconds after initial post

it took between 5 and 10 minutes for me to get the email1318.

Since an initial post is often followed by several posts containing minor edits, it's useful to wait a short period of time before sending an email1318. $MailPostsDelay is the minimum amount of time that must elapse from an initial post before a message is sent. A delay of zero means to immediately send a message whenever an update is received. Any additional posts occuring during the delay period are included in the message when it is sent. The message is sent on the first execution of pmwiki.php after the delay period has expired (which for inactive sites could be much longer than the delay period). pmwiki.php calls mail1318posts.php so if no one visits the section that calls mail1318posts.php the email1318 will be delayed. For clarification and an example using per Group settings: The $MailPostsDelay is set to 1800 (1/2 hour) in MyGroup and the person editing MyGroup finishes in less than 1/2 hour and leaves MyGroup. No one visits MyGroup again for two days. The email1318 message indicating that the editing of MyGroup has taken place will not be sent for two days. This will not be a problem as Site or Group activity increases.

$MailPostsSquelch specifies the minimum amount of time that must elapse before sending another notification message. This is useful to prevent large number of rapid-succession messages if $MailPostsDelay is set to a small value.

The defaults for $MailPostsDelay and $MailPostsSquelch are 0 and 7200. With these values, an email1318 is sent as soon as a page is changed, and subsequent changes are "held" for at least two hours before being sent in another message.

The variables used to control MailPosts are given below, and also described in the mail1318posts.php script.

Note for Windows installations

Sites running PHP under Windows may not have PHP's mail1318 function configured correctly. Such sites may need to add a line like

    ini_set('SMTP','smtp.server.com');

to config.php, where smtp.server.com is the name of your host's preferred outgoing mail1318 server.

MailPosts Variables

<< | Variables | >>

$EnableMailPosts
Tells stdconfig.php to enable the MailPosts script.
        $EnableMailPosts = 1;          # enable mail1318posts
        $EnableMailPosts = 0;          # disable mail1318posts
$MailPostsTo
A comma separated list of email1318 recipients.
        $MailPostsTo = 'admin@example.com, joe@somewhere.org';
$MailPostsFrom
Return email1318 address to be used in the sent email1318.
        $MailPostsFrom = 'wiki@example.com';
        $MailPostsFrom = 'Wiki server <wiki@example.com>';
$MailPostsDelay
The length of time (seconds) to wait before sending mail1318 after the first post. Defaults to zero - posts are sent as soon as the $MailPostsSquelch period has expired.
        $MailPostsDelay = 360;    # send mail1318 6+ min after first post
$MailPostsSquelch
The minimum length of time (seconds) that must elapse between sending mail1318 messages. Useful when $MailPostsDelay is set to a small value to keep the number of mail1318 notification messages down. Defaults to 7200 (two hours).
        $MailPostsSquelch = 43200;  # wait 12+ hours between mail1318ings
$MailPostsItemFmt
The text to be sent for each changed item in the post. The string "$PostTime" is substituted with the time of the post (controlled by $MailPostsTimeFmt below).
        # default
        $MailPostsItemFmt = ' * $FullName . . . $PostTime by $Author';
        # include the page's URL in the message
        $MailPostsItemFmt =
          " * \$FullName . . . \$PostTime by \$Author\n     \$PageUrl";
$MailPostsTimeFmt
The format for dates/times in $PostTime above. Defaults to the value of $TimeFmt.
        $MailPostsTimeFmt = 'm-H:%M';  # 2004-03-20 17:44
$MailPostsMessage
The body of the message to be sent. The string "$MailPostsList" is replaced with the list of posts (as formatted by $MailPostsItemFmt above).
$MailPostsSubject
The subject line of the mail1318 to be sent.
$MailPostsHeaders
String of extra mail1318 headers to be passed to the mail1318() function.
$MailPostsFunction
Name of the function to be called to send the mail1318. Defaults to using PHP's built-in mail1318() function, but some systems may not be configured correctly. Can be set to 'MailPostsSendmail1318' to explicitly call /usr/lib/sendmail1318.
        # call /usr/lib/sendmail1318 directly instead of using mail1318()
        $MailPostsFunction = 'MailPostsSendmail1318';
$MailPostsFile
The scratch file where MailPosts keeps track of recent posting information. Defaults to "$WikiDir/.mail1318posts". Note that this file must generally be writable by the webserver process.

Discussion that was here has been moved to PmWiki:MailPosts-Discussion.

<< | DocumentationIndex | >>

This page may have a more recent version on pmwiki.org: PmWiki:MailPosts, and a talk page: PmWiki:MailPosts-Talk.


Powered by PmWiki and the Sinorca skin