version=pmwiki-2.1.11 ordered=1 urlencoded=1
agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4
author=jm
csum=added trail
host=201.14.213.228
name=PmWiki.MailPosts
rev=57
targets=PmWiki.Variables,PmWiki.Notify,PmWiki.MailPosts,PmWiki.DocumentationIndex
text=%25audience%25 administrators (basic)%0a%3c%3c|[[PmWiki.Variables]]|>>%0a%0a->%25note%25 As of PmWiki 2.1.7, the MailPosts capability is being superceded by the more advanced ''notify.php'' script.  See [[Notify]] for details.%0a %0aThe ''mailposts.php'' script allows a site administrator to configure PmWiki to send email 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 email message (to avoid flooding a mailbox).%0a%0aThe 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.%0a%0aFull configuration details are available in ''scripts/mailposts.php''.%0a%0aBelow is a brief synopsis of what needs to go in '''config.php''' or a per-group customization script for MailPosts:%0a%0a %3c?php if (!defined('PmWiki')) exit();%0a $EnableMailPosts=1;                   # to enable mailposts%0a $MailPostsTo="somebody@example.com";  # where to send mail %0a $MailPostsDelay=1800;                 # wait 30+ min after initial post%0a $MailPostsSquelch=7200;               # require 2+ hours between mails%0a%0aNote that $MailPostsTo may be a comma-separated list of addresses if multiple recipients are desired.%0a%0a''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.  ''%0a%0aOn a per group basis you could set ''local/`MyGroup.php'' (Create the `MyGroup.php file if necessary) to:%0a%0a %3c?php if (!defined('PmWiki')) exit();%0a $EnableMailPosts=1;                           # Enable mailposts%0a $MailPostsTo="xxx@mail1.com, yyy@mail2.com";  # where to send mail%0a $MailPostsFrom="bbb@mail4.com";%0a $MailPostsDelay=1800;            # Wait 30+ minutes after initial post%0a $MailPostsSquelch=7200;          # Require 2+ hours between mails@]%0a $pagename = ResolvePageName($pagename);%0a $group = PageVar($pagename, '$Group');%0a $MailPostsMessage = "Recent wiki posts:\n"%0a    ."  ($ScriptUrl/$group/RecentChanges)\n\n\$MailPostsList\n";%0a $MailPostsFile = "$WorkDir/.$group.mailposts";%0a%0aNow make a change or add a document to one of the `MyGroup documents and save it. You should receive an email. Be patient. Even if you set (my test settings)%0a%0a $MailPostsDelay=18;              # Wait 18 seconds after initial post%0a $MailPostsSquelch=72;            # Wait 72 seconds after initial post%0a%0ait took between 5 and 10 minutes for me to get the email.%0a%0aSince 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 email.  $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 mailposts.php so if no one visits the section that calls mailposts.php the email 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 email 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.%0a%0a$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.  %0a%0aThe defaults for $MailPostsDelay and $MailPostsSquelch are 0 and 7200. With these values, an email 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.%0a%0aThe variables used to control MailPosts are given [[#variables | below]], and also described in the ''mailposts.php'' script.%0a%0a!!!Note for Windows installations%0a%0aSites running PHP under Windows may not have PHP's [[http://www.php.net/mail | mail]] function configured correctly.  Such sites may need to add a line like%0a%0a    ini_set('SMTP','smtp.server.com');%0a%0ato ''config.php'', where ''smtp.server.com'' is the name of your host's preferred outgoing mail server.%0a%0a!!![[#variables]] MailPosts Variables%0a%0a%3c%3c|Variables|>>%0a%0a:$EnableMailPosts:Tells ''stdconfig.php'' to enable the [[MailPosts]] script.%0a        $EnableMailPosts = 1;          # enable mailposts%0a        $EnableMailPosts = 0;          # disable mailposts%0a%0a:$MailPostsTo:A comma separated list of email recipients.%0a        $MailPostsTo = 'admin@example.com, joe@somewhere.org';%0a%0a:$MailPostsFrom:Return email address to be used in the sent email.%0a        $MailPostsFrom = 'wiki@example.com';%0a        $MailPostsFrom = 'Wiki server %3cwiki@example.com>';%0a%0a:$MailPostsDelay:The length of time (seconds) to wait before sending mail after the first post.  Defaults to zero - posts are sent as soon as the $MailPostsSquelch period has expired.%0a        $MailPostsDelay = 360;    # send mail 6+ min after first post%0a%0a:$MailPostsSquelch:The minimum length of time (seconds) that must elapse between sending mail messages.  Useful when $MailPostsDelay is set to a small value to keep the number of mail notification messages down.  Defaults to 7200 (two hours).%0a        $MailPostsSquelch = 43200;  # wait 12+ hours between mailings%0a%0a:$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).%0a        # default%0a        $MailPostsItemFmt = ' * $FullName . . . $PostTime by $Author';%0a        # include the page's URL in the message%0a        $MailPostsItemFmt =%0a          " * \$FullName . . . \$PostTime by \$Author\n     \$PageUrl";%0a%0a:$MailPostsTimeFmt:The format for dates/times in $PostTime above.  Defaults to the value of $TimeFmt.%0a        $MailPostsTimeFmt = '%25Y-%25m-%25d %25H:%25M';  # 2004-03-20 17:44%0a%0a:$MailPostsMessage:The body of the message to be sent.  The string "$MailPostsList" is replaced with the list of posts (as formatted by $MailPostsItemFmt above).%0a%0a:$MailPostsSubject:The subject line of the mail to be sent.%0a%0a:$MailPostsHeaders:String of extra mail headers to be passed to the mail() function.%0a%0a:$MailPostsFunction:Name of the function to be called to send the mail.  Defaults to using PHP's built-in @@[[http://www.php.net/mail | mail()]]@@ function, but some systems may not be configured correctly.  Can be set to [='MailPostsSendmail'=] to explicitly call ''/usr/lib/sendmail''.%0a        # call /usr/lib/sendmail directly instead of using mail()%0a        $MailPostsFunction = [='MailPostsSendmail'=];%0a%0a:$MailPostsFile:The scratch file where MailPosts keeps track of recent posting information.  Defaults to @@[="$WikiDir/.mailposts"=]@@.  Note that this file must generally be writable by the webserver process.%0a%0aDiscussion that was here has been moved to [[PmWiki:MailPosts-Discussion]].%0a%0a%25trail%25 %3c%3c|[[DocumentationIndex]]|>>
time=1152585055
