none
[openafs-wiki.git] / TWiki / MailerContrib.mdwn
1 # <a name="%TOPIC%"></a><a name=" %TOPIC%"></a> %TOPIC%
2
3 Add-on to the TWiki kernel that allows users to "subscribe" to regularly scheduled e-mails containing either:
4
5 - A report on changes to all topics that have changed within a particular TWiki web.
6 - A report on changes to a specific topic or set of topics the user can define flexibly.
7 - The entire content of a specific topic or set of topics. This is referred to as "news mode."
8
9 **WARNING: TWiki-4 only. If you want to use this extension with an earlier version of TWiki, please see [here](http://twiki.org/cgi-bin/view/Plugins/%TOPIC%?rev=1.17)**
10
11 <div>
12   <ul>
13     <li><a href="#tools/mailnotify"> <code>tools/mailnotify</code></a></li>
14     <li><a href="#TWiki/Contrib/_MailerContrib cod"> <code>TWiki/Contrib/MailerContrib</code> code library</a></li>
15     <li><a href="#package TWiki::Contrib::_MailerC"> package TWiki::Contrib::MailerContrib::WebNotify</a><ul>
16         <li><a href="#ClassMethod new($web, $topic)"> ClassMethod new($web, $topic)</a></li>
17         <li><a href="#ObjectMethod write_WebNotify()"> ObjectMethod writeWebNotify()</a></li>
18         <li><a href="#ObjectMethod getSubscriber($name"> ObjectMethod getSubscriber($name, $noAdd)</a></li>
19         <li><a href="#ObjectMethod getSubscribers()"> ObjectMethod getSubscribers()</a></li>
20         <li><a href="#ObjectMethod subscribe($name, $t"> ObjectMethod subscribe($name, $topics, $depth)</a></li>
21         <li><a href="#ObjectMethod unsubscribe($name,"> ObjectMethod unsubscribe($name, $topics, $depth)</a></li>
22         <li><a href="#ObjectMethod stringify() -> stri"> ObjectMethod stringify() -&gt; string</a></li>
23         <li><a href="#ObjectMethod processChange($chan"> ObjectMethod processChange($change, $db, $changeSet, $seenSet, $allSet)</a></li>
24         <li><a href="#ObjectMethod processCompulsory($"> ObjectMethod processCompulsory($topic, $db, \%allSet)</a></li>
25         <li><a href="#ObjectMethod isEmpty() -> boolea"> ObjectMethod isEmpty() -&gt; boolean</a></li>
26       </ul>
27     </li>
28     <li><a href="#package TWiki::Contrib::_MailerC"> package TWiki::Contrib::MailerContrib::Subscriber</a><ul>
29         <li><a href="#ClassMethod new($name)"> ClassMethod new($name)</a></li>
30         <li><a href="#ObjectMethod get_EmailAddresses("> ObjectMethod getEmailAddresses() -&gt; list</a></li>
31         <li><a href="#ObjectMethod subscribe($subs)"> ObjectMethod subscribe($subs)</a></li>
32         <li><a href="#ObjectMethod unsubscribe($subs)"> ObjectMethod unsubscribe($subs)</a></li>
33         <li><a href="#ObjectMethod is_SubscribedTo($to"> ObjectMethod isSubscribedTo($topic) -&gt; $subscription</a></li>
34         <li><a href="#ObjectMethod is_UnsubscribedFrom"> ObjectMethod isUnsubscribedFrom($topic) -&gt; $subscription</a></li>
35         <li><a href="#ObjectMethod stringify() -> stri"> ObjectMethod stringify() -&gt; string</a></li>
36       </ul>
37     </li>
38     <li><a href="#package TWiki::Contrib::_MailerC"> package TWiki::Contrib::MailerContrib::Subscription</a><ul>
39         <li><a href="#ClassMethod new($pages, $childDe"> ClassMethod new($pages, $childDepth, $news)</a></li>
40         <li><a href="#ObjectMethod stringify() -> stri"> ObjectMethod stringify() -&gt; string</a></li>
41         <li><a href="#ObjectMethod matches($topic, $db"> ObjectMethod matches($topic, $db, $depth) -&gt; boolean</a></li>
42         <li><a href="#ObjectMethod getMode() -> $mode"> ObjectMethod getMode() -&gt; $mode</a></li>
43       </ul>
44     </li>
45     <li><a href="#package TWiki::Contrib::_MailerC"> package TWiki::Contrib::MailerContrib::Change</a><ul>
46         <li><a href="#ClassMethod new($web)"> ClassMethod new($web)</a></li>
47         <li><a href="#ObjectMethod merge($change)"> ObjectMethod merge($change)</a></li>
48         <li><a href="#ObjectMethod expandHTML($html) -"> ObjectMethod expandHTML($html) -&gt; string</a></li>
49         <li><a href="#ObjectMethod expandPlain() -> st"> ObjectMethod expandPlain() -&gt; string</a></li>
50       </ul>
51     </li>
52     <li><a href="#package TWiki::Contrib::_MailerC"> package TWiki::Contrib::MailerContrib::UpData</a><ul>
53         <li><a href="#ClassMethod new($web)"> ClassMethod new($web)</a></li>
54         <li><a href="#ObjectMethod getParent($topic) -"> ObjectMethod getParent($topic) -&gt; string</a></li>
55       </ul>
56     </li>
57     <li><a href="#package TWiki::Contrib::Mailer"> package TWiki::Contrib::Mailer</a><ul>
58         <li><a href="#StaticMethod mailNotify($webs, $"> StaticMethod mailNotify($webs, $session, $verbose)</a></li>
59       </ul>
60     </li>
61     <li><a href="#Installation Instructions"> Installation Instructions</a><ul>
62         <li><a href="#Setting up your cron job(s)"> Setting up your cron job(s)</a></li>
63       </ul>
64     </li>
65     <li><a href="#Developer Notes"> Developer Notes</a><ul>
66         <li><a href="#Contrib Info"> Contrib Info</a></li>
67       </ul>
68     </li>
69   </ul>
70 </div>
71
72 # <a name="tools/mailnotify"></a> `tools/mailnotify`
73
74 The central component of [[MailerContrib]] is a script, `tools/mailnotify`, that generates and sends out the emails based on analysis of
75
76 1. users' subcriptions listed in the WebNotify topic in each web, and
77 2. changes within the respective webs.
78
79 This script is designed to be run from `cron` (or an equivalent off-line job scheduler), or from the command-line.
80
81 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
83 Each web can optionally contain a topic called WebNotify.
84
85 Users subscribe to email notifications using their [[WikiName]] or an alternative email address, and can specify the webs/topics they wish to track using one of these bullet list formats:
86
87 _three spaces_ \* [ _webname_ . ] _wikiName_ - _SMTP mail address_<br />_three spaces_ \* [ _webName_ . ] _wikiName_<br />_three spaces_ \* _SMTP mail address_<br />_three spaces_ \* _SMTP mail address_ : _topics_<br />_three spaces_ \* [ _webname_ . ] _wikiName_ : _topics_
88
89 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:
90
91 - Specify topics without a _Web._ prefix
92 - Topics must exist in this web.
93 - Topics may be specified using \* wildcards
94 - 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 ('+').
95 - 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.
96 - 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.
97
98 For example: Subscribe Daisy to all changes to topics in this web.
99
100        * daisy.cutter@flowers.com
101
102 Subscribe Daisy to all changes in all webs that start with `Web`.
103
104        * daisy.cutter@flowers.com: Web*
105
106 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`
107
108        * DaisyCutter: Petal* (1) WeedKillers (3) Pretty*Flowers
109
110 Subscribe StarTrekFan to changes to all topics that start with `Star` **except** those that end in `Wars`, `sInTheirEyes` or `shipTroopers`.
111
112        * StarTrekFan: Star* - *Wars - *sInTheirEyes - *shipTroopers
113
114 Subscribe Daisy to the full content of NewsLetter whenever it has changed
115
116        * daisy@flowers.com: NewsLetter?
117
118 Subscribe buttercup to NewsLetter and its immediate children, even if it hasn't changed.
119
120        * buttercup@flowers.com: NewsLetter! (1)
121
122 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]]:
123
124        * GardenGroup: AllNewsLetters? (3)
125        * petunia@flowers.com: - ManureNewsLetter
126
127 A user may be listed many times in the WebNotify topic. Where a user has several lines in WebNotify 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).
128
129 If a _TWiki group_ is listed for notification, the group will be recursively expanded to the e-mail addresses of all members.
130
131 **_%T% Tip:_** List names in alphabetical order to make it easier to find the names.
132
133 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.
134
135 %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%
136
137 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.
138
139 In addition, the %STARTPUBLISH% and %STOPPUBLISH% markers used by TWiki:Plugins.PublishContrib to delimit the text to be published are respected.
140
141 # <a name="TWiki/Contrib/_MailerContrib cod"></a> `TWiki/Contrib/MailerContrib` code library
142
143 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 `WebNotify` package described below.
144
145 # <a name="package TWiki::Contrib::_MailerC"></a> package TWiki::Contrib::MailerContrib::WebNotify
146
147 Object that represents the contents of a [[WebNotify]] topic in a TWiki web
148
149 ## <a name="ClassMethod new($web, $topic)"></a> [[ClassMethod]] new($web, $topic)
150
151 Create a new object by parsing the content of the given topic in the given web. This is the normal way to load a [[WebNotify]] topic. If the topic does not exist, it will create an empty object.
152
153 ## <a name="ObjectMethod write_WebNotify()"></a> [[ObjectMethod]] writeWebNotify()
154
155 Write the object to the [[WebNotify]] topic it was read from. If there is a problem writing the topic (e.g. it is locked), the method will return an error message. If everything is ok it will return undef.
156
157 ## <a name="ObjectMethod getSubscriber($name"></a> [[ObjectMethod]] getSubscriber($name, $noAdd)
158
159 - `$name` - Name of subscriber (wikiname with no web or email address)
160 - `$noAdd` - If false or undef, a new subscriber will be created for this name
161
162 Get a subscriber from the list of subscribers, and return a reference to the Subscriber object. If $noAdd is true, and the subscriber is not found, undef will be returned. Otherwise a new Subscriber object will be added if necessary.
163
164 ## <a name="ObjectMethod getSubscribers()"></a> [[ObjectMethod]] getSubscribers()
165
166 Get a list of all subscriber names (unsorted)
167
168 ## <a name="ObjectMethod subscribe($name, $t"></a> [[ObjectMethod]] subscribe($name, $topics, $depth)
169
170 - `$name` - Name of subscriber (wikiname with no web or email address)
171 - `$topics` - wildcard expression giving topics to subscribe to
172 - `$depth` - Child depth to scan (default 0)
173 - `$mode` - ! if this is a non-changes subscription and the topics should be mailed evebn if there are no changes. ? to mail the full topic only if there are changes. undef to mail changes only.
174
175 Add a subscription, adding the subscriber if necessary.
176
177 ## <a name="ObjectMethod unsubscribe($name,"></a><a name="ObjectMethod unsubscribe($name, "></a> [[ObjectMethod]] unsubscribe($name, $topics, $depth)
178
179 - `$name` - Name of subscriber (wikiname with no web or email address)
180 - `$topics` - wildcard expression giving topics to subscribe to
181 - `$depth` - Child depth to scan (default 0)
182
183 Add an unsubscription, adding the subscriber if necessary. An unsubscription is a specific request to ignore notifications for a topic for this particular subscriber.
184
185 ## <a name="ObjectMethod stringify() - strin"></a> [[ObjectMethod]] stringify() -&gt; string
186
187 Return a string representation of this object, in [[WebNotify]] format.
188
189 ## <a name="ObjectMethod processChange($chan"></a> [[ObjectMethod]] processChange($change, $db, $changeSet, $seenSet, $allSet)
190
191 - `$change` - ref of a TWiki::Contrib::Mailer::Change
192 - `$db` - TWiki::Contrib::MailerContrib::UpData database of parent references
193 - `$changeSet` - ref of a hash mapping emails to sets of changes
194 - `$seenSet` - ref of a hash recording indices of topics already seen
195 - `$allSet` - ref of a hash that maps topics to email addresses for news subscriptions
196
197 Find all subscribers that are interested in the given change. Only the most recent change to each topic listed in the .changes file is retained. This method does _not_ change this object.
198
199 ## <a name="ObjectMethod processCompulsory($"></a> [[ObjectMethod]] processCompulsory($topic, $db, \\%allSet)
200
201 - `$topic` - topic name
202 - `$db` - TWiki::Contrib::MailerContrib::UpData database of parent references
203 - `\%allSet` - ref of a hash that maps topics to email addresses for news subscriptions
204
205 ## <a name="ObjectMethod isEmpty() - boolean"></a> [[ObjectMethod]] isEmpty() -&gt; boolean
206
207 Return true if there are no subscribers
208
209 # <a name="package TWiki::Contrib::_MailerC"></a> package TWiki::Contrib::MailerContrib::Subscriber
210
211 Object that represents a subscriber to notification. A subscriber is a name (which may be a wikiName or an email address) and a list of subscriptions which describe the topis subscribed to, and unsubscriptions representing topics they are specifically not interested in. The subscriber name may also be a group, so it may expand to many email addresses.
212
213 ## <a name="ClassMethod new($name)"></a> [[ClassMethod]] new($name)
214
215 - `$name` - Wikiname, with no web, or email address, of user targeted for notification
216
217 Create a new user.
218
219 ## <a name="ObjectMethod get_EmailAddresses("></a> [[ObjectMethod]] getEmailAddresses() -&gt; list
220
221 Get a list of email addresses for the user(s) represented by this subscription
222
223 ## <a name="ObjectMethod subscribe($subs)"></a> [[ObjectMethod]] subscribe($subs)
224
225 - `$subs` - Subscription object
226
227 Add a new subscription to this subscriber object. The subscription will always be added, even if there is a wildcard overlap with an existing subscription.
228
229 ## <a name="ObjectMethod unsubscribe($subs)"></a> [[ObjectMethod]] unsubscribe($subs)
230
231 - `$subs` - Subscription object
232
233 Add a new unsubscription to this subscriber object. The unsubscription will always be added, even if there is a wildcard overlap with an existing subscription or unsubscription.
234
235 An unsubscription is a statement of the subscribers desire _not_ to be notified of changes to this topic.
236
237 ## <a name="ObjectMethod is_SubscribedTo($to"></a> [[ObjectMethod]] isSubscribedTo($topic) -&gt; $subscription
238
239 - `$topic` - Topic object we are checking
240 - `$db` - TWiki::Contrib::MailerContrib::UpData database of parents
241
242 Check if we have a subscription to the given topic. Return the subscription that matches if we do, undef otherwise.
243
244 ## <a name="ObjectMethod is_UnsubscribedFrom"></a> [[ObjectMethod]] isUnsubscribedFrom($topic) -&gt; $subscription
245
246 - `$topic` - Topic object we are checking
247 - `$db` - TWiki::Contrib::MailerContrib::UpData database of parents
248
249 Check if we have an unsubscription from the given topic. Return the subscription that matches if we do, undef otherwise.
250
251 ## <a name="ObjectMethod stringify() - strin"></a> [[ObjectMethod]] stringify() -&gt; string
252
253 Return a string representation of this object, in WebNotify format.
254
255 # <a name="package TWiki::Contrib::_MailerC"></a> package TWiki::Contrib::MailerContrib::Subscription
256
257 Object that represents a single subscription of a user to notification on a page. A subscription is expressed as a page spec (which may contain wildcards) and a depth of children of matching pages that the user is subscribed to.
258
259 ## <a name="ClassMethod new($pages, $childDe"></a> [[ClassMethod]] new($pages, $childDepth, $news)
260
261 - `$pages` - Wildcarded expression matching subscribed pages
262 - `$childDepth` - Depth of children of $topic to notify changes for. Defaults to 0
263 - `$mode` - ! if this is a non-changes subscription and the topics should be mailed evebn if there are no changes. ? to mail the full topic only if there are changes. undef to mail changes only.
264
265 Create a new subscription.
266
267 ## <a name="ObjectMethod stringify() - strin"></a> [[ObjectMethod]] stringify() -&gt; string
268
269 Return a string representation of this object, in WebNotify format.
270
271 ## <a name="ObjectMethod matches($topic, $db"></a> [[ObjectMethod]] matches($topic, $db, $depth) -&gt; boolean
272
273 - `$topic` - Topic object we are checking
274 - `$db` - TWiki::Contrib::MailerContrib::UpData database of parent names
275 - `$depth` - If non-zero, check if the parent of the given topic matches as well. undef = 0.
276
277 Check if we match this topic. Recurses up the parenthood tree seeing if this is a child of a parent that matches within the depth range.
278
279 ## <a name="ObjectMethod getMode() - $mode"></a> [[ObjectMethod]] getMode() -&gt; $mode
280
281 Return ! if this is a non-changes subscription and the topics should be mailed even if there are no changes. ? to mail the full topic only if there are changes. undef to mail changes only.
282
283 ----
284
285 # <a name="package TWiki::Contrib::_MailerC"></a> package TWiki::Contrib::MailerContrib::Change
286
287 Object that represents a change to a topic.
288
289 ## <a name="ClassMethod new($web)"></a> [[ClassMethod]] new($web)
290
291 - `$web` - Web name
292 - `$topic` - Topic name
293 - `$author` - String author of change
294 - `$time` - String time of change
295 - `$rev` - Revision identifier
296
297 Construct a new change object.
298
299 ## <a name="ObjectMethod merge($change)"></a> [[ObjectMethod]] merge($change)
300
301 - `$change` - Change record to merge
302
303 Merge another change record with this one, so that the combined record is a reflection of both changes.
304
305 ## <a name="ObjectMethod expandHTML($html) -"></a> [[ObjectMethod]] expandHTML($html) -&gt; string
306
307 - `$html` - Template to expand keys within
308
309 Expand an HTML template using the values in this change. The following keys are expanded: %TOPICNAME%, %AUTHOR%, %TIME%, %REVISION%, %TEXTHEAD%.
310
311 Returns the expanded template.
312
313 ## <a name="ObjectMethod expandPlain() - str"></a> [[ObjectMethod]] expandPlain() -&gt; string
314
315 Generate a plaintext version of this change.
316
317 # <a name="package TWiki::Contrib::_MailerC"></a> package TWiki::Contrib::MailerContrib::UpData
318
319 Object that lazy-scans topics to extract parent relationships.
320
321 ## <a name="ClassMethod new($web)"></a> [[ClassMethod]] new($web)
322
323 - `$web` - Web we are building parent relationships for
324
325 Constructor for a web; initially empty, will lazy-load as topics are referenced.
326
327 ## <a name="ObjectMethod getParent($topic) -"></a> [[ObjectMethod]] getParent($topic) -&gt; string
328
329 Get the name of the parent topic of the given topic
330
331 # <a name="package TWiki::Contrib::Mailer"></a> package TWiki::Contrib::Mailer
332
333 Package of support for extended WebNotify notification, supporting per-topic notification and notification of changes to children.
334
335 Also supported is a simple API that can be used to change the WebNotify topic from other code.
336
337 ## <a name="StaticMethod mailNotify($webs, $"></a> [[StaticMethod]] mailNotify($webs, $session, $verbose)
338
339 - `$webs` - filter list of names webs to process. Wildcards (\*) may be used.
340 - `$session` - optional session object. If not given, will use a local object.
341 - `$verbose` - true to get verbose (debug) output
342
343 Main entry point.
344
345 Process the WebNotify topics in each web and generate and issue notification mails. Designed to be invoked from the command line; should only be called by `mailnotify` scripts.
346
347 # <a name="Installation Instructions"></a> Installation Instructions
348
349 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.
350
351 Like many other TWiki extensions, this module is shipped with a fully automatic installer script written using the BuildContrib.
352
353 - If you have TWiki 4.1 or later, and Perl 5.8, you can install from the `configure` interface (Go to Plugins-&gt;Find More Extensions)
354   - The webserver user has to have permission to write to all areas of your installation for this to work.
355 - If you have a permanent connection to the internet (and Perl 5.8), you are recommended to use the automatic installer script
356   - Just download the `MailerContrib_installer` perl script and run it.
357 - **Notes:**
358   - The installer script will:
359     - Automatically resolve dependencies,
360     - Copy files into the right places in your local install (even if you have renamed data directories),
361     - check in new versions of any installed files that have existing RCS histories files in your existing install (such as topics).
362     - 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.
363     - (Developers only: the script will look for twikiplugins/MailerContrib/MailerContrib.tgz before downloading from TWiki.org)
364   - 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.
365     - Point the environment variable `$TWIKI_PACKAGES` to this directory, and the installer script will look there first for required TWiki packages.
366       - `$TWIKI_PACKAGES` is actually a path; you can list several directories separated by :
367     - 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](http://twiki.org/cgi-bin/view/Codev/BuildingDakar#CPAN_local_minimirror)
368 - 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:
369   1. Download and unpack one of the `.zip` or `.tgz` archives to a temporary directory.
370   2. Manually copy the contents across to the relevant places in your TWiki installation.
371   3. 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)
372   4. Manually edit LocalSite.cfg to set any configuration variables.
373   5. Run `configure` and enable the module, if it is a plugin.
374   6. Repeat from step 1 for any missing dependencies.
375
376 - 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.
377
378 ## <a name="Setting up your cron job(s)"></a> Setting up your cron job(s)
379
380 You need to set up a `cron` (or equivalent) job to run `tools/mailnotify`.
381
382 Usage: <code>perl -I &lt;bin&gt; mailnotify [-q] [-news] [ _web1 web2 ... webN_ ]</code> &lt;bin&gt; is the path to the TWiki bin directory, so that the script can find the rest of TWiki.
383
384 <table border="1" cellpadding="0" cellspacing="0">
385   <tr>
386     <td><code>-q</code></td>
387     <td> Don't print progress information </td>
388   </tr>
389   <tr>
390     <td><code>-news</code></td>
391     <td> Run in news mode (process NewsNotify instead of WebNotify) </td>
392   </tr>
393   <tr>
394     <td><code><i>web1 web2 ... webN</i></code></td>
395     <td> List of webs to process, separated by spaces or commas. Default is to process all legal TWiki webs. Wildcards (*) are supported. </td>
396   </tr>
397 </table>
398
399 For example, assuming TWiki was installed at `/usr/local/twiki`, this cron entry:
400
401     0 0 * * * cd /usr/local/twiki && perl -I bin tools/mailnotify -q Public Private
402
403 will generate change notifications for the `Public` and `Private` webs every night at midnight.
404
405     0 0 * * 0 cd /usr/local/twiki && perl -I bin tools/mailnotify -news
406
407 will generate newsletters from **all** webs every week on midnight Saturday.
408
409 # <a name="Developer Notes"></a> Developer Notes
410
411 The changes mails sent to users are based on a TWiki template called `mailnotify`. This template must contain the following definitions.
412
413 <table border="1" cellpadding="0" cellspacing="0">
414   <tr>
415     <td><code>HTML:before</code></td>
416     <td> Section of a HTML mail before the changes </td>
417   </tr>
418   <tr>
419     <td><code>HTML:middle</code></td>
420     <td> Repeated in a HTML mail for each change </td>
421   </tr>
422   <tr>
423     <td><code>HTML:after</code></td>
424     <td> Section of a HTML mail after the changes </td>
425   </tr>
426   <tr>
427     <td><code>PLAIN:before</code></td>
428     <td> Section of a plain text mail before the changes </td>
429   </tr>
430   <tr>
431     <td><code>PLAIN:middle</code></td>
432     <td> Repeated in a plain text mail for each changes </td>
433   </tr>
434   <tr>
435     <td><code>PLAIN:after</code></td>
436     <td> Section of a plain text mail after the changes </td>
437   </tr>
438   <tr>
439     <td><code>MailNotifyBody</code></td>
440     <td> All the above are embedded in this. %HTML_TEXT% expands to the HTML obtained by expanding the <code>HTML:*</code> templates, and %PLAIN_TEXT% from the <code>PLAIN:*</code> templates. </td>
441   </tr>
442 </table>
443
444 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.
445
446 Newsletters are sent after formatting using the standard `view` template, using whatever skin is selected in the topic being mailed.
447
448 ## <a name="Contrib Info"></a> Contrib Info
449
450 <table border="1" cellpadding="0" cellspacing="0">
451   <tr>
452     <td align="right"> Author: </td>
453     <td> TWiki:Main/CrawfordCurrie (<a href="http://c-dot.co.uk" target="_top">http://c-dot.co.uk</a>) </td>
454   </tr>
455   <tr>
456     <td align="right"> Copyright ©: </td>
457     <td> 2004, Wind River Systems; 2006, <a href="http://WikiRing.com" target="_top">http://WikiRing.com</a></td>
458   </tr>
459   <tr>
460     <td align="right"> License: </td>
461     <td> GPL </td>
462   </tr>
463   <tr>
464     <td align="right"> Change History: </td>
465     <td>   </td>
466   </tr>
467   <tr>
468     <td align="right"> 12496 </td>
469     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item3415" rel="nofollow">Item3415</a> mailnotify did not send notifications to intranet users because of wrong call to findUser. </td>
470   </tr>
471   <tr>
472     <td align="right"> 11672 </td>
473     <td> Added newsletter support, after much harassment from TWiki:Main.LynnwoodBrown </td>
474   </tr>
475   <tr>
476     <td align="right"> 11534 </td>
477     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item2153" rel="nofollow">Item2153</a> Clarified docs. <a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item2698" rel="nofollow">Item2698</a> Improved error reporting. </td>
478   </tr>
479   <tr>
480     <td align="right"> 8808 </td>
481     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1654" rel="nofollow">Item1654</a> mailnotify must enter the command_line context </td>
482   </tr>
483   <tr>
484     <td align="right"> 8625 </td>
485     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1508" rel="nofollow">Item1508</a> Making the dashes in the separatator clearer </td>
486   </tr>
487   <tr>
488     <td align="right"> 8606 </td>
489     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1508" rel="nofollow">Item1508</a> [[Main/MailerContrib]]: Brushing up HTML mailnotify template </td>
490   </tr>
491   <tr>
492     <td align="right"> 8602 </td>
493     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1508" rel="nofollow">Item1508</a> [[Main/MailerContrib]]: Cleaning up plaintext e-mail template, removing TEXTAREA </td>
494   </tr>
495   <tr>
496     <td align="right"> 8522 </td>
497     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1511" rel="nofollow">Item1511</a> arguments to getScriptUrl in wrong order :-( </td>
498   </tr>
499   <tr>
500     <td align="right"> 8434 </td>
501     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1465" rel="nofollow">Item1465</a> Fix 'TWiki.' to '%TWIKIEB%.' </td>
502   </tr>
503   <tr>
504     <td align="right"> 8398 </td>
505     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1460" rel="nofollow">Item1460</a> polished up the comment a bit </td>
506   </tr>
507   <tr>
508     <td align="right"> 8308 </td>
509     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1362" rel="nofollow">Item1362</a> moving mailnotify cron script </td>
510   </tr>
511   <tr>
512     <td align="right"> 7848 </td>
513     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item1167" rel="nofollow">Item1167</a> forced all mail operations to generate absolute URLs </td>
514   </tr>
515   <tr>
516     <td align="right"> 7568 </td>
517     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item910" rel="nofollow">Item910</a> use SCRIPTURL{view} instead of complex url expr </td>
518   </tr>
519   <tr>
520     <td align="right"> 6864 </td>
521     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item624" rel="nofollow">Item624</a> mailer templates moved the the right places </td>
522   </tr>
523   <tr>
524     <td align="right"> 6861 </td>
525     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item624" rel="nofollow">Item624</a> Added proper templates support for plain text mails </td>
526   </tr>
527   <tr>
528     <td align="right"> 6809 </td>
529     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item623" rel="nofollow">Item623</a> don't print anything if verbosity is switched off. </td>
530   </tr>
531   <tr>
532     <td align="right"> 6659 </td>
533     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item528" rel="nofollow">Item528</a> Updated [[Main/MailerContrib]]. it's working and the sendmail parameter is used. </td>
534   </tr>
535   <tr>
536     <td align="right"> 6474 </td>
537     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item420" rel="nofollow">Item420</a> removed spurious remove_obsolete_locks from [[Main/MailerContrib]]</td>
538   </tr>
539   <tr>
540     <td align="right"> 5924 </td>
541     <td><a href="http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item153" rel="nofollow">Item153</a> fix mail URL-fixing scheme </td>
542   </tr>
543   <tr>
544     <td align="right"> 5269 </td>
545     <td> Minor doc fixes </td>
546   </tr>
547   <tr>
548     <td align="right"> 5266 </td>
549     <td> Doc tidy-ups, added filtering of _ webs, added obsolete lock script </td>
550   </tr>
551   <tr>
552     <td align="right"> 5264 </td>
553     <td> Changed default to add web name to user name (I hope) </td>
554   </tr>
555   <tr>
556     <td align="right"> 5263 </td>
557     <td> Minor doc tidyups </td>
558   </tr>
559   <tr>
560     <td align="right"> 5261 </td>
561     <td> Documentation changes, and fixed to scan all webs. </td>
562   </tr>
563   <tr>
564     <td align="right"> 5253 </td>
565     <td> runnable as CGI script, minor bugfixes, removed dependency on [[Main/DBCacheContrib]]</td>
566   </tr>
567   <tr>
568     <td align="right"> 5234 </td>
569     <td> Minor doc changes </td>
570   </tr>
571   <tr>
572     <td align="right"> 5231 </td>
573     <td> Made a change an object, added unit tests to CVS, lots of testing. </td>
574   </tr>
575   <tr>
576     <td align="right"> 4 March 2005 </td>
577     <td> 1.010 Dakar release ready. </td>
578   </tr>
579   <tr>
580     <td align="right"> 12 Oct 2004 </td>
581     <td> 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) </td>
582   </tr>
583   <tr>
584     <td align="right"> 6 Oct 2004 </td>
585     <td> 1.003 Excluded _ webs from processing, added <code>bin/remove_obsolete_locks</code> for full reverse-compatibility </td>
586   </tr>
587   <tr>
588     <td align="right"> 1 Oct 2004 </td>
589     <td> 1.002 PeterThoeny provided additional documentation </td>
590   </tr>
591   <tr>
592     <td align="right"> 27 Sep 2004 </td>
593     <td> 1.001 runnable as CGI script, minor bugfixes, removed dependency on DBCacheContrib </td>
594   </tr>
595   <tr>
596     <td align="right"> 8 Sep 2004 </td>
597     <td> 1.000 Initial version </td>
598   </tr>
599   <tr>
600     <td align="right"> Home: </td>
601     <td> TWiki:Plugins/%TOPIC% </td>
602   </tr>
603   <tr>
604     <td align="right"> Feedback: </td>
605     <td> TWiki:Plugins/%TOPIC%Dev </td>
606   </tr>
607   <tr>
608     <td align="right"> Appraisal: </td>
609     <td><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal</a></td>
610   </tr>
611 </table>