[Pmwiki-users] MailPosts configuration

Shel Holtz shel
Mon Sep 27 10:43:34 CDT 2004

I've been trying to get the mailposts file working. Following is the way I have it configured in my configure.php file, and following my signature block is the mailposts.php file itself. (Note that sendmail is at /opt/CommuniGate/sendmail)

Thanks for the assist. I continue to be a non-coder trying to get this working for my professional use:

  $PageTemplateFmt = "pub/skins/pmwiki/lean/lean.tmpl";
  $PrintTemplateFmt = "pub/skins/pmwiki/lean/lean-print.tmpl";
  $WikiTitle = "TheEmployeeCommunicationsManifestoWiki";
  $PageLogoUrl = "http://darkstar.holtz.com/pmwiki/pub/skins/pmwiki/ecm2.gif";

Shel Holtz, ABC
Holtz Communication + Technology
E-mail: shel at holtz.com
Web:    www.holtz.com
Blog:   blog.holtz.com
Author, "Corporate Conversations"
  and "Public Relations on the Net"

<?php if (!defined('PmWiki')) exit();
/*  Copyright 2002-2004 Patrick R. Michaud (pmichaud at pobox.com)
    This file is part of PmWiki; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.  See pmwiki.php for full details.

    This script enables email notifications to be sent whenever posts
    are made.  It is included by default from the stdconfig.php
    script if $EnableMailPosts is set to non-zero.  Be sure to set
    the $MailPostsTo variable or the scratch file will grow without

    To explicitly enable this feature, execute
    from config.php somewhere.

    Several variables control the functioning of this script:

    $MailPostsTo - comma separated list of email recipients
    $MailPostsFrom - return email address
    $MailPostsDelay - number of seconds to wait before sending mail after
      the first post.  Useful so that lots of small edits result are
      batched together in a single email message.  However, mail
      won't be sent until the first execution of pmwiki.php after the
      delay has expired, which could be much longer than the delay period
      itself depending on how active your site is.
    $MailPostsSquelch - minimum number of seconds between sending mail
      messages.  Useful when $MailPostsDelay is set to a small value
      to prevent large numbers of mail notifications to be sent.
    $MailPostsFile - scratch file used to keep track of recent posts
    $MailPostsMessage - body of message to be sent.  The sequence
      '$MailPostsList' is replaced with the list of changes.
    $MailPostTimeFmt - the format for dates and times in $PostTime
    $MailPostItemFmt - the text to be sent for each changed item in the post.
      The string $PostTime contains the time of the post formatted
      according to $MailPostTimeFmt.
    $MailPostsSubject - subject line for mail to be sent
    $MailPostsHeaders - string of extra headers for mail (passed to PHP
       mail() function, some headers may not work for PHP < 4.3).
    $MailPostsFunction - If the default PHP mail function isn't working
       for you, then you can define your own mail function here or you
       can try "MailPostsSendmail".

SDV($MailPostsMessage,"Recent wiki posts:\n"
  ."  ($ScriptUrl/Main/AllRecentChanges)\n\n\$MailPostsList\n");
SDV($MailPostsSubject,"$WikiTitle recent wiki posts");
SDV($MailPostsItemFmt,' * $PageName . . . $PostTime by $Author');
if (@$MailPostsFrom)
  $MailPostsHeaders = "From: $MailPostsFrom\r\n$MailPostsHeaders";

if ($action=='post' || @$_POST['post']) {
  $fp = @fopen($MailPostsFile,"a");
  if ($fp) {
    $PostTime = strftime($MailPostsTimeFmt,$Now);
      FmtPageName("$Now $MailPostsItemFmt",$pagename))."\n");

if (@$MailPostsTo="shel at holtz.com") return;
$fp = @fopen($MailPostsFile,"r");
if (!$fp) return;
$oldestpost = $Now+1; $mailpost=array();
while (!feof($fp)) {
  @(list($t,$p) = explode(' ',rtrim(fgets($fp,1024)),2));
  if (!$t) continue;
  if ($p=='#lastmailed') {
    if ($t > $Now-$MailPostsSquelch) { fclose($fp); return; }
  if ($t<$oldestpost) $oldestpost=$t;

if ($oldestpost > $Now-$MailPostsDelay) { Lock(0); return; }

$fp = @fopen($MailPostsFile,"w");
if ($fp) { fputs($fp,"$Now #lastmailed\n"); fclose($fp); }

function MailPostsSendmail($to,$subject,$msg,$headers) {
  if (preg_match('/From: .*?([-.\w]+@[-.\w]+)/',$headers,$match))
  $mailer = popen("/opt/CommuniGate/sendmail -t -i $from","w");
  fwrite($mailer,"To: $to\nSubject: $subject\n$headers\n\n$msg");


More information about the pmwiki-users mailing list