9 date 2008.08.03.22.17.45; author TWikiContributor; state Exp;
14 date 2008.01.22.03.21.28; author TWikiContributor; state Exp;
19 date 2007.01.16.04.11.59; author TWikiContributor; state Exp;
24 date 2006.06.25.16.26.31; author TWikiContributor; state Exp;
29 date 2006.04.01.05.55.29; author TWikiContributor; state Exp;
34 date 2006.02.01.12.01.22; author TWikiContributor; state Exp;
49 @---+!! Mailer Contrib
50 <a href="http://wikiring.com"><img src="%ATTACHURL%/logo.gif" style="float:right" /></a>
52 Allows users to "subscribe" to regularly scheduled e-mails containing either:
53 * A report on changes to all topics that have changed within a particular TWiki web.
54 * A report on changes to a specific topic or set of topics the user can define flexibly.
55 * The entire content of a specific topic or set of topics. This is referred to as "news mode."
56 * The companion plugin (TWiki:Plugins.SubscribePlugin) lets you trivially add a "Subscribe to changes" button to topics
60 PLEASE DO NOT EDIT THIS TOPIC
62 It is automatically generated from the subversion repository, and any changes
63 you make will simply be overwritten the next time a release is generated.
65 Instead, you could check your fix in, raise a bug in the Bugs web, or mail the author.
69 <div class="twikiBroadcastMessage">WARNING: TWiki-4 only. If you want to use this extension with an earlier version of TWiki, please use [[http://twiki.org/cgi-bin/attach/Plugins/%TOPIC%?filename=%TOPIC%.zip&revInfo=1][revision 17 of the zip]].</div>
73 ---++ tools/mailnotify
75 The central component of !MailerContrib is a script, =tools/mailnotify=, that generates and sends out the emails based on analysis of
76 1 users' subcriptions listed in the <nop>%NOTIFYTOPIC% topic in each web, and
77 1 changes within the respective webs.
78 This script is designed to be run from =cron= (or an equivalent off-line job scheduler), or from the command-line.
80 The script collates the changes emails so that each subscriber only receives one changes notification for all changes in all webs in the TWiki. Furthermore, users can elect to receive just summaries of changes, or the entire content of topics that have changed.
82 Each web can optionally contain a topic called <nop>%NOTIFYTOPIC%.
83 <!-- Included by %TWIKIWEB%.WebChangesAlert -->
85 Users subscribe to email notifications using their [[%TWIKIWEB%.WikiName][WikiName]] or an alternative email address, and can specify the webs/topics they wish to track, Whole groups of users can also be subscribed for notification.
87 The general format of a subscription is:
89 _three spaces_ =*= _subscriber_ [ =:= _topics_ ]
91 Where _subscriber_ can be a [[%TWIKIWEB%.WikiName][WikiName]], an E-mail address, or a
92 group name. If _subscriber_ contains any characters that are not legal in
93 an email address, then it must be enclosed in 'single' or "double" quotes.
95 _topics_ is an optional space-separated list of topics:
96 * ... *without* a _Web._ prefix
97 * ...that exist in this web.
98 Users may further customize the specific content they will receive using the following controls:
99 * *Using wild-card character in topic names* - You can use =*= in a topic name, where it is treated as a [[http://en.wikipedia.org/wiki/Wildcard_character][wildcard character]]. A =*= will match zero or more other characters - so, for example, =Fred*= will match all topic names starting with =Fred=, =*Fred= will match all topic names _ending_ with =Fred=, and =*= will match _all_ topic names.
100 * *Unsubscribing to specific topics* - Each topic may optionally be preceded by a '+' or '-' sign. The '+' sign means "subscribe to this topic". The '-' sign means "unsubscribe" or "don't send notifications regarding this particular topic". This allows users to elect to filter out certain topics. Topic filters ('-') take precedence over topic includes ('+') i.e. if you unsubscribe from a topic it will cancel out any subscriptions to that topic.
101 * *Including child-topics in subscription* - Each topic may optionally be followed by an integer in parentheses, indicating the depth of the tree of children below that topic. Changes in all these children will be detected and reported along with changes to the topic itself. _Note_ This uses the TWiki "Topic parent" feature.
102 * *Subscribing to entire topic ("news mode")* - Each topic may optionally be immediately followed by an exclamation mark ! or a question mark ? with no intervening spaces, indicating that the topic (and children if there is a tree depth specifier as well) should be mailed out as *complete topics* instead of change summaries. ! causes the topic to be mailed every time _even if there have been no changes_, and ? will mail the topic only if there have been changes to it. One can limit the content of the subscribed topic to send out by inserting %<nop>STARTPUBLISH% and %<nop>STOPPUBLISH% markers within the topic. Note that "news mode" subscriptions require a corresponding cron job that includes the "-news" option (see [[%TOPIC%#Setting_up_your_cron_job_s][details]]).
105 Subscribe Daisy to all changes to topics in this web.
107 * daisy.cutter@@flowers.com
109 Subscribe Daisy to all changes to topics that start with =Web=.
111 * daisy.cutter@@flowers.com : Web*
113 Subscribe Daisy to changes to topics starting with =Petal=, and their immediate children, !WeedKillers and children to a depth of 3, and all topics that match start with =Pretty= and end with =Flowers= e.g. =PrettyPinkFlowers=
115 * DaisyCutter: Petal* (1) WeedKillers (3) Pretty*Flowers
117 Subscribe !StarTrekFan to changes to all topics that start with =Star= *except* those that end in =Wars=, =sInTheirEyes= or =shipTroopers=.
119 * StarTrekFan: Star* - *Wars - *sInTheirEyes - *shipTroopers
121 Subscribe Daisy to the full content of !NewsLetter whenever it has changed
123 * daisy@@flowers.com: NewsLetter?
125 Subscribe buttercup to !NewsLetter and its immediate children, even if it hasn't changed.
127 * buttercup@@flowers.com: NewsLetter! (1)
129 Subscribe !GardenGroup (which includes Petunia) to all changed topics under !AllnewsLetters to a depth of 3. Then unsubscribe Petunia from the !ManureNewsLetter, which she would normally get as a member of GardenGroup:
131 * GardenGroup: AllNewsLetters? (3)
132 * petunia@@flowers.com: - ManureNewsLetter
134 Subscribe =IT:admins= (a non-TWiki group defined by an alternate user mapping) to all changes to Web* topics.
139 A user may be listed many times in the <nop>%NOTIFYTOPIC% topic. Where a user has several lines in <nop>%NOTIFYTOPIC% that all match the same topic, they will only be notified about _changes_ that topic _once_ (though they will still receive individual mails for news topics).
141 If a _group_ is listed for notification, the group will be recursively expanded to the e-mail addresses of all members.
143 __%X% Warning: Because an email address is not linked to a user name, there is no way for TWiki to check access controls for email addresses. A user identified by an email address will only be sent change notifications if the topic they are asubscribed to is readable by guest users. You can limit what email addresses can be used in <nop>%NOTIFYTOPIC%, or even block use of emails altogther, using the ={MailerContrib}{EmailFilterIn} setting in =configure=.
145 __%T% Tip:__ List names in alphabetical order to make it easier to find the names.
148 In the future it is intended that individual users will be able to control the frequency with which they are notified of topic changes, by changing a schedule specification in their home topic. However at present, the notification schedule is controlled by the frequency of activation of the =cron= job that runs the =mailnotify= script.
150 Note that when using the "news mode" =!= or =?= specifiers the entire topic text is mailed out as HTML. The =newsletter= template is used to generate the content in this mail, using whatever skin is selected in the topic being mailed.
152 In addition, the %<nop>STARTPUBLISH% and %<nop>STOPPUBLISH% markers used by TWiki:Plugins.PublishContrib to delimit the text to be published are respected in news mode.
154 ---++ TWiki/Contrib/MailerContrib code library
155 The second part of the module is a code library that provides the services for other applications to modify the subscription topics through a clean, well documented API. This allows (for example) plugin developers to add (for example) a "Register me for this newsletter" button to their pages. Developers should refer to the POD documentation for the !WebNotify class as their starting point.
157 ---++ Installation Instructions
158 You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server where TWiki is running.
160 Like many other TWiki extensions, this module is shipped with a fully
161 automatic installer script written using the Build<nop>Contrib.
162 * If you have TWiki 4.2 or later, you can install from the =configure= interface (Go to Plugins->Find More Extensions)
163 * See the [[http://twiki.org/cgi-bin/view/Plugins/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information.
164 * If you have any problems, then you can still install manually from the command-line:
165 1 Download one of the =.zip= or =.tgz= archives
166 1 Unpack the archive in the root directory of your TWiki installation.
167 1 Run the installer script ( =perl <module>_installer= )
168 1 Run =configure= and enable the module, if it is a plugin.
169 1 Repeat for any missing dependencies.
170 * If you are *still* having problems, then instead of running the installer script:
171 1 Make sure that the file permissions allow the webserver user to access all files.
172 1 Check in any installed files that have existing =,v= files in your existing install (take care *not* to lock the files when you check in)
173 1 Manually edit !LocalSite.cfg to set any configuration variables.
175 %IF{"defined 'SYSTEMWEB'" else="<div class='twikiAlert'>%X% WARNING: SYSTEMWEB is not defined in this TWiki. Please add these definitions to your %MAINWEB%.TWikiPreferences, if they are not already there:<br><pre> * <nop>Set SYSTEMWEB = %<nop>TWIKIWEB%<br> * <nop>Set USERSWEB = %<nop>MAINWEB%</pre></div>"}%
177 * To make sure the installation was successful, run the =mailnotify= script from the command line, with no parameters. In this case it will print out what it would have done to =STDOUT=.
178 *Additional settings*
179 * You can change the regular expression that matches email addresses in <nop>%NOTIFYTOPIC% using the ={MailerContrib}{EmailFilterIn} setting in =configure=. This allows you to limit the domains to which emails can be sent, or even block email addresses altogether.
181 ---+++ Setting up your cron job(s)
182 You need to set up a =cron= (or equivalent) job to run the =tools/mailnotify= perl script.
184 The script is used as follows: <code>perl -I _bin_ mailnotify [-q] [-news] [ <i>web1 web2 ... webN</i> ]</code>
185 | _bin_ | path to the TWiki bin directory, so that the script can find the rest of TWiki. |
186 | =-q= | Don't print progress information |
187 | =-news= | Run in "news mode" (process subscriptions that include "!" or "?" following the topic) |
188 | <code><i>web1 web2 ... webN</i></code> | List of webs to process, separated by spaces or commas. The default is to process all webs. Wildcards (*) are supported. |
189 For example, assuming TWiki was installed at =/usr/local/twiki=, this cron entry:
191 0 0 * * * cd /usr/local/twiki && perl -I bin tools/mailnotify -q Public Private
193 will generate change notifications for the =Public= and =Private= webs every night at midnight. (Google for =crontab= for more information on what all the =0 0 * * *= fields mean)
195 0 0 * * * cd /usr/local/twiki && perl -I bin tools/mailnotify -q -Sandbox
197 will generate change notifications for all webs, except the =Sandbox= web.
199 0 0 * * 0 cd /usr/local/twiki && perl -I bin tools/mailnotify -news
201 will generate newsletters from *all* webs every week on midnight Saturday.
203 %X% Note: Multiple instances of mailnotify script are not allowed to be executed simutaneously. If you need to run the script multiple times with different options, make sure the cron jobs are scheduled so a previous run has finished before the next starts. You can also write a small script that runs mailnotify in sequence as described in TWiki:Support.DuplicateNotificationsFromMailerCon.
206 * Set STUB = TWiki::Contrib::Mailer
207 * Set SHORTDESCRIPTION = Supports e-mail notification of changes.
209 ---++ Developer Notes
210 The changes mails sent to users are based on a TWiki template called =mailnotify=. This template must contain the following definitions.
211 | =HTML:before= | Section of a HTML mail before the changes |
212 | =HTML:middle= | Repeated in a HTML mail for each change |
213 | =HTML:after= | Section of a HTML mail after the changes |
214 | =PLAIN:before= | Section of a plain text mail before the changes |
215 | =PLAIN:middle= | Repeated in a plain text mail for each changes |
216 | =PLAIN:after= | Section of a plain text mail after the changes |
217 | =MailNotifyBody= | All the above are embedded in this. %<nop>HTML_TEXT% expands to the HTML obtained by expanding the =HTML:*= templates, and %<nop>PLAIN_TEXT% from the =PLAIN:*= templates. |
218 The default template sends multipart mails containing both HTML and plaintext versions. You can easily provide a custom version of this template using a local skin.
220 Newsletters are sent after formatting using the standard =view= template, using whatever skin is selected in the topic being mailed.
224 Another great TWiki extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiring.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience!
226 Many thanks to the following sponsors for supporting this work:
227 * [[http://www.windriver.com][Wind River]]
228 * [[http://wikigardens.com][WikiGardens]]
230 | Author: | TWiki:Main/CrawfordCurrie (http://c-dot.co.uk) |
231 | Copyright ©: | 2004, Wind River Systems; 2006, http://WikiRing.com |
233 | Version: | 03 Aug 2008 |
234 | Change History: | |
235 | 03 Aug 2008 | TWiki 4.2.1 release version |
236 | 27 Jul 2008 | TWikibug:Item5776: TWiki:Main.KennethLavrsen added note to warn against running multiple instances of mailnotify at the same time. |
237 | 15 May 2008 | TWikibug:Item5232: TWiki:Main.CrawfordCurrie added support for non-ascii alphanumerics in topic names to WebNotify. TWikibug:Item5630: TWiki:Main.SvenDowideit fixed some spelling errors |
238 | 25 Jan 2008 | TWikibug:Item4812: added TWiki:Main.BobGoldstein's noexpand patch for groups |
239 | 2 Nov 2007 | TWikibug:Item4818: added quotes to support non-alphabetic and other wierd group names TWikibug:Item4887: corrected minor rendering error TWikibug:Item4917: removed dependence on symbolic web names |
240 | 9 Sep 2007 | TWikibug:Item4326 workaround for possible error in !WebNotify API in old releases, Should not affect most users. |
241 | 6 Sep 2007 | TWikibug:Item4488 doc tweaks |
242 | 14550 | TWikibug:Item4461 - 'Changed' link now points to most recent changes, not the entire history |
243 | 22 Jun 2007 | TWikibug:Item4284 - added access control checks and email filter |
244 | 21 May 2007 | TWikibug:Item3969 - 8bit email fix (TWiki:Main.WillNorris) |
245 | 13623 | TWikibug:Item4014 no changes was resetting the notify time to 0. Thanks to TWiki:Main.JeffCrawford for nailing this down. |
246 | 12496 | TWikibug:Item3415 mailnotify did not send notifications to intranet users because of wrong call to findUser. |
247 | 11672 | Added newsletter support, after much harassment from TWiki:Main.LynnwoodBrown |
248 | 11534 | TWikibug:Item2153 Clarified docs. TWikibug:Item2698 Improved error reporting. |
249 | 8808 | TWikibug:Item1654 mailnotify must enter the command_line context |
250 | 8625 | TWikibug:Item1508 Making the dashes in the separatator clearer |
251 | 8606 | TWikibug:Item1508 MailerContrib: Brushing up HTML mailnotify template |
252 | 8602 | TWikibug:Item1508 MailerContrib: Cleaning up plaintext e-mail template, removing TEXTAREA |
253 | 8522 | TWikibug:Item1511 arguments to getScriptUrl in wrong order :-( |
254 | 8434 | TWikibug:Item1465 Fix 'TWiki.' to '%TWIKIEB%.' |
255 | 8398 | TWikibug:Item1460 polished up the comment a bit |
256 | 8308 | TWikibug:Item1362 moving mailnotify cron script |
257 | 7848 | TWikibug:Item1167 forced all mail operations to generate absolute URLs |
258 | 7568 | TWikibug:tem910 use SCRIPTURL{view} instead of complex url expr |
259 | 6864 | TWikibug:tem624 mailer templates moved the the right places |
260 | 6861 | TWikibug:tem624 Added proper templates support for plain text mails |
261 | 6809 | TWikibug:tem623 don't print anything if verbosity is switched off. |
262 | 6659 | TWikibug:tem528 Updated MailerContrib. it's working and the sendmail parameter is used. |
263 | 6474 | TWikibug:tem420 removed spurious remove_obsolete_locks from MailerContrib |
264 | 5924 | TWikibug:tem153 fix mail URL-fixing scheme |
265 | 5269 | Minor doc fixes |
266 | 5266 | Doc tidy-ups, added filtering of _ webs, added obsolete lock script |
267 | 5264 | Changed default to add web name to user name (I hope) |
268 | 5263 | Minor doc tidyups |
269 | 5261 | Documentation changes, and fixed to scan all webs. |
270 | 5253 | runnable as CGI script, minor bugfixes, removed dependency on DBCacheContrib |
271 | 5234 | Minor doc changes |
272 | 5231 | Made a change an object, added unit tests to CVS, lots of testing. |
273 | 4 March 2005 | 1.010 Dakar release ready. |
274 | 12 Oct 2004 | 1.004 Added support for anti-subscriptions. Doc fixes from TWiki:Main.PeterThoeny. Bug fixes to permissions code. Back-off and retry if the mailer can't be reached (should really be in Net::sendEmail) |
275 | 6 Oct 2004 | 1.003 Excluded _ webs from processing, added =bin/remove_obsolete_locks= for full reverse-compatibility |
276 | 1 Oct 2004 | 1.002 Peter<nop>Thoeny provided additional documentation |
277 | 27 Sep 2004 | 1.001 runnable as CGI script, minor bugfixes, removed dependency on DB<nop>CacheContrib |
278 | 8 Sep 2004 | 1.000 Initial version |
279 | Home: | TWiki:Plugins/%TOPIC% |
280 | Feedback: | TWiki:Plugins/%TOPIC%Dev |
281 | Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |
283 %META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" version="1"}%
284 %META:FILEATTACHMENT{name="logo.gif" attr="h" comment="" version="1"}%
296 1 changes within the respective webs.
299 Users subscribe to email notifications using their %TWIKIWEB%.WikiName or an alternative email address, and can specify the webs/topics they wish to track, WWhole groups of users can also be subscribed for notification.
302 Where _subscriber_ can be a %TWIKIWEB%.WikiName, an E-mail address, or a
305 * You can use =*= in a topic name, where it is treated as a [[http://en.wikipedia.org/wiki/Wildcard_character][wildcard character]]. A =*= will match zero or more other characters - so, for example, =Fred*= will match all topic names starting with =Fred=, =*Fred= will match all topic names _ending_ with =Fred=, and =*= will match _all_ topic names.
306 * Each topic may optionally be preceded by a '+' or '-' sign. The '+' sign means "subscribe to this topic". The '-' sign means "unsubscribe" or "don't send notifications regarding this particular topic". This allows users to elect to filter out certain topics. Topic filters ('-') take precedence over topic includes ('+') i.e. if you unsubscribe from a topic it will cancel out any subscriptions to that topic.
307 * Each topic may optionally be followed by an integer in parentheses, indicating the depth of the tree of children below that topic. Changes in all these children will be detected and reported along with changes to the topic itself. _Note_ This uses the TWiki "Topic parent" feature.
308 * Each topic may optionally be immediately followed by an exclamation mark ! or a question mark ? with no intervening spaces, indicating that the topic (and children if there is a tree depth specifier as well) should be mailed out as *complete topics* instead of change summaries. ! causes the topic to be mailed every time _even if there have been no changes_, and ? will mail the topic only if there have been changes to it. This only makes sense for subscriptions, and is intended for mailshotting regular newletters.
314 | =-news= | Run in news mode (process !NewsNotify instead of <nop>%NOTIFYTOPIC%) |
318 | Version: | 16078 (22 Jan 2008) |
321 | 2 Nov 2007 | Bugs:Item4818: added quotes to support non-alphabetic and other wierd group names Bugs:Item4887: corrected minor rendering error Bugs:Item4917: removed dependence on symbolic web names |
322 | 9 Sep 2007 | Bugs:Item4326 workaround for possible error in !WebNotify API in old releases, Should not affect most users. |
323 | 6 Sep 2007 | Bugs:Item4488 doc tweaks |
324 | 14550 | Bugs:Item4461 - 'Changed' link now points to most recent changes, not the entire history |
325 | 22 Jun 2007 | Bugs:Item4284 - added access control checks and email filter |
326 | 21 May 2007 | Bugs:Item3969 - 8bit email fix (TWiki:Main.WillNorris) |
327 | 13623 | Bugs:Item4014 no changes was resetting the notify time to 0. Thanks to TWiki:Main.JeffCrawford for nailing this down. |
328 | 12496 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item3415'>Item3415</a> mailnotify did not send notifications to intranet users because of wrong call to findUser. |
331 | 11534 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item2153'>Item2153</a> Clarified docs. <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item2698'>Item2698</a> Improved error reporting. |
332 | 8808 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1654'>Item1654</a> mailnotify must enter the command_line context |
333 | 8625 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1508'>Item1508</a> Making the dashes in the separatator clearer |
334 | 8606 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1508'>Item1508</a> MailerContrib: Brushing up HTML mailnotify template |
335 | 8602 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1508'>Item1508</a> MailerContrib: Cleaning up plaintext e-mail template, removing TEXTAREA |
336 | 8522 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1511'>Item1511</a> arguments to getScriptUrl in wrong order :-( |
337 | 8434 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1465'>Item1465</a> Fix 'TWiki.' to '%TWIKIEB%.' |
338 | 8398 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1460'>Item1460</a> polished up the comment a bit |
339 | 8308 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1362'>Item1362</a> moving mailnotify cron script |
340 | 7848 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1167'>Item1167</a> forced all mail operations to generate absolute URLs |
341 | 7568 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item910'>Item910</a> use SCRIPTURL{view} instead of complex url expr |
342 | 6864 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item624'>Item624</a> mailer templates moved the the right places |
343 | 6861 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item624'>Item624</a> Added proper templates support for plain text mails |
344 | 6809 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item623'>Item623</a> don't print anything if verbosity is switched off. |
345 | 6659 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item528'>Item528</a> Updated MailerContrib. it's working and the sendmail parameter is used. |
346 | 6474 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item420'>Item420</a> removed spurious remove_obsolete_locks from MailerContrib |
347 | 5924 | <a rel='nofollow' href='http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item153'>Item153</a> fix mail URL-fixing scheme |
358 %META:TOPICINFO{author="TWikiAdminGroup" date="1168425636" format="1.1" version="4"}%
362 Add-on to the TWiki kernel that allows users to "subscribe" to regularly scheduled e-mails containing either:
366 *WARNING: TWiki-4 only. If you want to use this extension with an earlier version of TWiki, please see [[http://twiki.org/cgi-bin/view/Plugins/%TOPIC%?rev=1.17][here]]*
369 ---+ <code>tools/mailnotify</code>
370 The central component of MailerContrib is a script, =tools/mailnotify=, that generates and sends out the emails based on analysis of
373 Users subscribe to email notifications using their %TWIKIWEB%.WikiName or an alternative email address, and can specify the webs/topics they wish to track using one of these bullet list formats:
376 _three spaces_ * [ _webname_ . ] _wikiName_ - _SMTP mail address_ <br />
377 _three spaces_ * [ _webName_ . ] _wikiName_ <br />
378 _three spaces_ * _SMTP mail address_ <br />
379 _three spaces_ * _SMTP mail address_ : _topics_ <br />
380 _three spaces_ * [ _webname_ . ] _wikiName_ : _topics_
382 In the above examples, _topics_ is a space-separated list of topic names. The user may further customize the specific content they will receive using the following formats:
383 * Specify topics without a _Web._ prefix
384 * Topics must exist in this web.
385 * Topics may be specified using * wildcards
386 * Each topic may optionally be preceded by a '+' or '-' sign. The '+' sign means "subscribe to this topic" (the same as not putting anything). The '-' sign means "unsubscribe" or "don't send notifications regarding this topic". This allows users to elect to filter out certain topics (and their children, to an arbitrary depth). Topic filters ('-') take precedence over topic includes ('+').
389 * Each topic may optionally be immediately followed by an exclamation mark ! or a question mark ? with no intervening spaces, indicating that the topic (and children if there is a tree depth specifier as well) should be mailed out as *complete topics* instead of change summaries. ! causes the topic to be mailed every time even if there have been no changes, ? will mail the topic only if there have been changes to it. This only makes sense for subscriptions.
392 Subscribe Daisy to all changes in all webs that start with =Web=.
395 * daisy.cutter@@flowers.com: Web*
399 If a _TWiki group_ is listed for notification, the group will be recursively expanded to the e-mail addresses of all members.
402 %RED% __Note__ =mailnotify= ignores permissions in webs. It is entirely possible for a user to get added to one of the subscription topics in a web, when they are not authorised to view the topics in that web. This could result in them having access to sensitive information, particularly with news mode. %ENDCOLOR%
404 Note that when using the "news mode" ! or ? specifiers are used the entire topic text is mailed out as HTML. The =newsletter= template is used to generate the content in this mail, using whatever skin is selected in the topic being mailed.
406 In addition, the %<nop>STARTPUBLISH% and %<nop>STOPPUBLISH% markers used by TWiki:Plugins.PublishContrib to delimit the text to be published are respected.
408 ---+ <code>TWiki/Contrib/MailerContrib</code> code library
409 The second part of the module is a code library that provides the services for other applications to modify the subscription topics through a clean, well documented API. This allows (for example) plugin developers to add (for example) a "Register me for this newsletter" button to their pages. The main interface is the =Web<nop>Notify= package described below.
411 ---+ package TWiki::Contrib::MailerContrib::WebNotify
412 Object that represents the contents of a %NOTIFYTOPIC% topic in a TWiki web
415 ---++ ClassMethod new($web, $topic)
416 Create a new object by parsing the content of the given topic in the
417 given web. This is the normal way to load a %NOTIFYTOPIC% topic. If the
418 topic does not exist, it will create an empty object.
421 ---++ ObjectMethod writeWebNotify()
422 Write the object to the %NOTIFYTOPIC% topic it was read from.
423 If there is a problem writing the topic (e.g. it is locked),
424 the method will return an error message. If everything is ok
425 it will return undef.
428 ---++ ObjectMethod getSubscriber($name, $noAdd)
429 * =$name= - Name of subscriber (wikiname with no web or email address)
430 * =$noAdd= - If false or undef, a new subscriber will be created for this name
431 Get a subscriber from the list of subscribers, and return a reference
432 to the Subscriber object. If $noAdd is true, and the subscriber is not
433 found, undef will be returned. Otherwise a new Subscriber object will
434 be added if necessary.
437 ---++ ObjectMethod getSubscribers()
438 Get a list of all subscriber names (unsorted)
441 ---++ ObjectMethod subscribe($name, $topics, $depth)
442 * =$name= - Name of subscriber (wikiname with no web or email address)
443 * =$topics= - wildcard expression giving topics to subscribe to
444 * =$depth= - Child depth to scan (default 0)
445 * =$mode= - ! if this is a non-changes subscription and the topics should
446 be mailed evebn if there are no changes. ? to mail the full topic only
447 if there are changes. undef to mail changes only.
448 Add a subscription, adding the subscriber if necessary.
451 ---++ ObjectMethod unsubscribe($name, $topics, $depth)
452 * =$name= - Name of subscriber (wikiname with no web or email address)
453 * =$topics= - wildcard expression giving topics to subscribe to
454 * =$depth= - Child depth to scan (default 0)
455 Add an unsubscription, adding the subscriber if necessary. An unsubscription
456 is a specific request to ignore notifications for a topic for this
457 particular subscriber.
460 ---++ ObjectMethod stringify() -> string
461 Return a string representation of this object, in %NOTIFYTOPIC% format.
464 ---++ ObjectMethod processChange($change, $db, $changeSet, $seenSet, $allSet)
465 * =$change= - ref of a TWiki::Contrib::Mailer::Change
466 * =$db= - TWiki::Contrib::MailerContrib::UpData database of parent references
467 * =$changeSet= - ref of a hash mapping emails to sets of changes
468 * =$seenSet= - ref of a hash recording indices of topics already seen
469 * =$allSet= - ref of a hash that maps topics to email addresses for news subscriptions
470 Find all subscribers that are interested in the given change. Only the most
471 recent change to each topic listed in the .changes file is retained. This
472 method does _not_ change this object.
475 ---++ ObjectMethod processCompulsory($topic, $db, \%allSet)
476 * =$topic= - topic name
477 * =$db= - TWiki::Contrib::MailerContrib::UpData database of parent references
478 * =\%allSet= - ref of a hash that maps topics to email addresses for news subscriptions
481 ---++ ObjectMethod isEmpty() -> boolean
482 Return true if there are no subscribers
485 ---+ package TWiki::Contrib::MailerContrib::Subscriber
486 Object that represents a subscriber to notification. A subscriber is
487 a name (which may be a wikiName or an email address) and a list of
488 subscriptions which describe the topis subscribed to, and
489 unsubscriptions representing topics they are specifically not
490 interested in. The subscriber
491 name may also be a group, so it may expand to many email addresses.
494 ---++ ClassMethod new($name)
495 * =$name= - Wikiname, with no web, or email address, of user targeted for notification
499 ---++ ObjectMethod getEmailAddresses() -> list
500 Get a list of email addresses for the user(s) represented by this
504 ---++ ObjectMethod subscribe($subs)
505 * =$subs= - Subscription object
506 Add a new subscription to this subscriber object.
507 The subscription will always be added, even if there is
508 a wildcard overlap with an existing subscription.
511 ---++ ObjectMethod unsubscribe($subs)
512 * =$subs= - Subscription object
513 Add a new unsubscription to this subscriber object.
514 The unsubscription will always be added, even if there is
515 a wildcard overlap with an existing subscription or unsubscription.
517 An unsubscription is a statement of the subscribers desire _not_
518 to be notified of changes to this topic.
521 ---++ ObjectMethod isSubscribedTo($topic) -> $subscription
522 * =$topic= - Topic object we are checking
523 * =$db= - TWiki::Contrib::MailerContrib::UpData database of parents
524 Check if we have a subscription to the given topic. Return the subscription
525 that matches if we do, undef otherwise.
528 ---++ ObjectMethod isUnsubscribedFrom($topic) -> $subscription
529 * =$topic= - Topic object we are checking
530 * =$db= - TWiki::Contrib::MailerContrib::UpData database of parents
531 Check if we have an unsubscription from the given topic. Return the subscription that matches if we do, undef otherwise.
535 ---++ ObjectMethod stringify() -> string
536 Return a string representation of this object, in Web<nop>Notify format.
540 ---+ package TWiki::Contrib::MailerContrib::Subscription
541 Object that represents a single subscription of a user to
542 notification on a page. A subscription is expressed as a page
543 spec (which may contain wildcards) and a depth of children of
544 matching pages that the user is subscribed to.
547 ---++ ClassMethod new($pages, $childDepth, $news)
548 * =$pages= - Wildcarded expression matching subscribed pages
549 * =$childDepth= - Depth of children of $topic to notify changes for. Defaults to 0
550 * =$mode= - ! if this is a non-changes subscription and the topics should
551 be mailed evebn if there are no changes. ? to mail the full topic only
552 if there are changes. undef to mail changes only.
553 Create a new subscription.
556 ---++ ObjectMethod stringify() -> string
557 Return a string representation of this object, in Web<nop>Notify format.
560 ---++ ObjectMethod matches($topic, $db, $depth) -> boolean
561 * =$topic= - Topic object we are checking
562 * =$db= - TWiki::Contrib::MailerContrib::UpData database of parent names
563 * =$depth= - If non-zero, check if the parent of the given topic matches as well. undef = 0.
564 Check if we match this topic. Recurses up the parenthood tree seeing if
565 this is a child of a parent that matches within the depth range.
568 ---++ ObjectMethod getMode() -> $mode
569 Return ! if this is a non-changes subscription and the topics should
570 be mailed even if there are no changes. ? to mail the full topic only
571 if there are changes. undef to mail changes only.
575 ---+ package TWiki::Contrib::MailerContrib::Change
576 Object that represents a change to a topic.
579 ---++ ClassMethod new($web)
581 * =$topic= - Topic name
582 * =$author= - String author of change
583 * =$time= - String time of change
584 * =$rev= - Revision identifier
585 Construct a new change object.
588 ---++ ObjectMethod merge($change)
589 * =$change= - Change record to merge
590 Merge another change record with this one, so that the combined
591 record is a reflection of both changes.
594 ---++ ObjectMethod expandHTML($html) -> string
595 * =$html= - Template to expand keys within
596 Expand an HTML template using the values in this change. The following
597 keys are expanded: %<nop>TOPICNAME%, %<nop>AUTHOR%, %<nop>TIME%,
598 %<nop>REVISION%, %<nop>TEXTHEAD%.
600 Returns the expanded template.
603 ---++ ObjectMethod expandPlain() -> string
604 Generate a plaintext version of this change.
607 ---+ package TWiki::Contrib::MailerContrib::UpData
608 Object that lazy-scans topics to extract
609 parent relationships.
612 ---++ ClassMethod new($web)
613 * =$web= - Web we are building parent relationships for
614 Constructor for a web; initially empty, will lazy-load as topics
618 ---++ ObjectMethod getParent($topic) -> string
619 Get the name of the parent topic of the given topic
622 ---+ package TWiki::Contrib::Mailer
624 Package of support for extended Web<nop>Notify notification, supporting per-topic notification and notification of changes to children.
626 Also supported is a simple API that can be used to change the Web<nop>Notify topic from other code.
629 ---++ StaticMethod mailNotify($webs, $session, $verbose)
630 * =$webs= - filter list of names webs to process. Wildcards (*) may be used.
631 * =$session= - optional session object. If not given, will use a local object.
632 * =$verbose= - true to get verbose (debug) output
636 Process the Web<nop>Notify topics in each web and generate and issue
637 notification mails. Designed to be invoked from the command line; should
638 only be called by =mailnotify= scripts.
642 ---+ Installation Instructions
645 Like many other TWiki extensions, this module is shipped with a fully automatic installer script written using the Build<nop>Contrib.
646 * If you have TWiki 4.1 or later, and Perl 5.8, you can install from the =configure= interface (Go to Plugins->Find More Extensions)
647 * The webserver user has to have permission to write to all areas of your installation for this to work.
648 * If you have a permanent connection to the internet (and Perl 5.8), you are recommended to use the automatic installer script
649 * Just download the =MailerContrib_installer= perl script and run it.
651 * The installer script will:
652 * Automatically resolve dependencies,
653 * Copy files into the right places in your local install (even if you have renamed data directories),
654 * check in new versions of any installed files that have existing RCS histories files in your existing install (such as topics).
655 * If the $TWIKI_PACKAGES environment variable is set to point to a directory, the installer will try to get archives from there. Otherwise it will try to download from twiki.org or cpan.org, as appropriate.
656 * (Developers only: the script will look for twikiplugins/MailerContrib/MailerContrib.tgz before downloading from TWiki.org)
657 * If you don't have a permanent connection, you can still use the automatic installer, by downloading all required TWiki archives to a local directory.
658 * Point the environment variable =$TWIKI_PACKAGES= to this directory, and the installer script will look there first for required TWiki packages.
659 * =$TWIKI_PACKAGES= is actually a path; you can list several directories separated by :
660 * If you are behind a firewall that blocks access to CPAN, you can build a local CPAN mini-mirror, as described at http://twiki.org/cgi-bin/view/Codev/BuildingDakar#CPAN_local_minimirror
661 * If you don't want to use the installer script, or have problems on your platform (e.g. you don't have Perl 5.8), then you can still install manually:
662 1 Download and unpack one of the =.zip= or =.tgz= archives to a temporary directory.
663 1 Manually copy the contents across to the relevant places in your TWiki installation.
665 1 Run =configure= and enable the module, if it is a plugin.
666 1 Repeat from step 1 for any missing dependencies.
669 * To make sure the installation was successful, run the =mailnotify= script from the command line, with no parameters. In this case it will print out what it would have done to STDOUT.
672 ---++ Setting up your cron job(s)
673 You need to set up a =cron= (or equivalent) job to run =tools/mailnotify=.
676 Usage: <code>perl -I <bin> mailnotify [-q] [-news] [ <i>web1 web2 ... webN</i> ]</code>
677 <bin> is the path to the TWiki bin directory, so that the script can find the rest of TWiki.
680 | <code><i>web1 web2 ... webN</i></code> | List of webs to process, separated by spaces or commas. Default is to process all legal TWiki webs. Wildcards (*) are supported. |
683 will generate change notifications for the =Public= and =Private= webs every night at midnight.
706 Add-on to the TWiki kernel that supports e-mail notification of changes.
709 ---++ Summary of Contents
710 ---+++ <code>tools/mailnotify</code>
711 The main part of the mailer module is a script, =tools/mailnotify=. This script is designed to be run from 'cron' (or an equivalent offline job scheduler), and processes the contents of the standard <nop>%NOTIFYTOPIC% topic. As well as providing the usual notification service, it also provides per-topic notification services. The script may be run from the command line or a cron job.
715 Subscribers are listed in <nop>%NOTIFYTOPIC% following one of these bullet list formats:
718 where _topics_ is a space-separated list of topic names.
722 * Each topic may optionally be preceded by a '+' or '-' sign. The '+' sign means "subscribe to this topic" (the same as not putting anything). The '-' sign means "don't send notifications regarding this topic". This allows users to elect to filter out changes to certain topics (and their children, to an arbitrary depth). Topic filters ('-') take precedence over topic includes ('+').
727 * daisy@@flowers.com: Web*
728 * DaisyCutter: Petal* (1) WeedKillers (3) Red*Phlox
729 * StarTrekFan: * - *Wars - *sInTheirEyes - *shipTroopers
732 A user may be listed many times in the <nop>%NOTIFYTOPIC% topic. Where a user has several lines in <nop>%NOTIFYTOPIC% that all match the same topic, they will only be notified of changes to that topic _once_.
735 %RED% __Note__ =mailnotify= ignores permissions in webs. It is entirely possible for a user to get added to a <nop>%NOTIFYTOPIC% topic in a web, when they are not authorised to view the topics in that web. This could result in them having limited access to sensitive information (the topic summaries). %ENDCOLOR%
737 ---+++ <code>TWiki/Contrib/MailerContrib</code> code library
738 The second part of the module is a code library that provides the services for other applications to modify <nop>%NOTIFYTOPIC% through a clean, well documented interface. This allows (for example) plugin developers to add a "Register me for notification" button to their pages. The main interface is the =Web<nop>Notify= package described below.
741 ---++ Installation Instructions
742 This Contrib is pre-installed as part of the TWiki release package, and should only have to be re-installed if an upgrade is required.
743 * Download the ZIP file from the Plugin web (see below)
744 * Unzip ==%TOPIC%.zip== in your twiki installation directory.
745 * Run the installer script =MailContrib_intaller.pl= or alternatively resolve all dependencies manually.
748 ---++ Setting up your cron job
749 You need to set up a =cron= (or equivalent) job to run =mailnotify=.
752 <code>Usage: perl -I <bin> mailnotify [-q] [ <i>web1 web2 ... webN</i> ]</code>
753 <bin> is the path to the TWiki bin directory (usually =../bin=), so that the script can find the rest of TWiki.
757 For example, =perl -I /usr/local/twiki/bin mailnotify -q Public Private= will generate notifications for the Public and Private webs.
764 | Copyright ©: | 2004, Wind River Systems |
767 | Change History: | |
768 | 8808 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1654'>Item1654</a> mailnotify must enter the command_line context |
769 | 8625 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1508'>Item1508</a> Making the dashes in the separatator clearer |
770 | 8606 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1508'>Item1508</a> MailerContrib: Brushing up HTML mailnotify template |
771 | 8602 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1508'>Item1508</a> MailerContrib: Cleaning up plaintext e-mail template, removing TEXTAREA |
772 | 8522 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1511'>Item1511</a> arguments to getScriptUrl in wrong order :-( |
773 | 8434 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1465'>Item1465</a> Fix 'TWiki.' to '%TWIKIEB%.' |
774 | 8398 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1460'>Item1460</a> polished up the comment a bit |
775 | 8308 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1362'>Item1362</a> moving mailnotify cron script |
776 | 7848 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item1167'>Item1167</a> forced all mail operations to generate absolute URLs |
777 | 7568 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item910'>Item910</a> use SCRIPTURL{view} instead of complex url expr |
778 | 6864 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item624'>Item624</a> mailer templates moved the the right places |
779 | 6861 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item624'>Item624</a> Added proper templates support for plain text mails |
780 | 6809 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item623'>Item623</a> don't print anything if verbosity is switched off. |
781 | 6659 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item528'>Item528</a> Updated MailerContrib. it's working and the sendmail parameter is used. |
782 | 6474 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item420'>Item420</a> removed spurious remove_obsolete_locks from MailerContrib |
783 | 5924 | <a rel='nofollow' href='http://develop.twiki.org/~develop/cgi-bin/view/Bugs/Item153'>Item153</a> fix mail URL-fixing scheme |
784 | 5269 | Minor doc fixes |
785 | 5266 | Doc tidy-ups, added filtering of _ webs, added obsolete lock script |
786 | 5264 | Changed default to add web name to user name (I hope) |
787 | 5263 | Minor doc tidyups |
788 | 5261 | Documentation changes, and fixed to scan all webs. |
789 | 5253 | runnable as CGI script, minor bugfixes, removed dependency on DBCacheContrib |
790 | 5234 | Minor doc changes |
791 | 5231 | Made a change an object, added unit tests to CVS, lots of testing. |
802 %META:TOPICINFO{author="TWikiContributor" date="1111929255" format="1.0" version="2"}%
805 Instead, you could check your fix in, raise a bug in the Bugs web, or mail thge author.
808 This module is an add-on to the TWiki kernel that supports e-mail notification of changes.
811 ---+ Summary of Contents
812 ---++ <code>tools/mailnotify</code>
815 ---++ <code>TWiki/Contrib/MailerContrib</code> code library
818 ---+ Installation Instructions
821 ---+ Setting up your cron job
824 <code>Usage: perl -I <bin> tools/mailnotify [-q] [ <i>web1 web2 ... webN</i> ]</code>
825 <bin> is the path to the TWiki bin directory, so that the script can find the rest of TWiki.
829 * Name of the perl package
830 * Set STUB = TWiki::Contrib::Mailer
836 __Related Topics:__ %TWIKIWEB%.TWikiPreferences
838 -- TWiki:Main/CrawfordCurrie
849 %META:TOPICINFO{author="TWikiContributor" date="1111929255" format="1.0" version="1"}%
854 * Specify topics without a _Web._ prefix
855 * Topics must exist in this web.
856 * Topics may be specified using * wildcards
857 * Each topic may optionally be followed by an integer in parentheses, indicating the depth of the tree of children below that topic. Changes in all these children will be detected and reported along with changes to the topic itself. _Note_ This uses the TWiki "Topic parent" feature.
858 * Each topic may optionally be preceded by a '+' or '-' sign. The '+' sign means "subscribe to this topic" (the same as not putting anything). The '-' sign means "don't send notifications regarding this topic". This allows users to elect to filter out changes to certain topics (and their children, to an arbitrary depth). Topic filters ('-') take precedence over topic includes ('+').
862 * daisy@@flowers.com: Web*
863 * DaisyCutter: Petal* (1) WeedKillers (3) Red*Phlox
864 * StarTrekFan: * - *Wars - *sInTheirEyes - *shipTroopers
867 * Download the ZIP file from the Plugin web (see below)
868 * Unzip ==%TOPIC%.zip== in your twiki installation directory.
869 * Run the installer script =MailContrib_intaller.pl= or alternatively resolve all dependencies manually.
870 * To make sure the installation was successful, run the =mailnotify= script from the command line, with no parameters. In this case it will print out what it would have done to STDOUT.
873 * Name of the perl package
874 * Set STUB = TWiki::Contrib::Mailer
877 | Change History: | <!-- versions below in reverse order --> |