Makes sure wgAdditionalMailParams is null in safe mode
[lhc/web/wiklou.git] / includes / UserMailer.php
1 <?php
2 /**
3 * Classes used to send e-mails
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @author <brion@pobox.com>
22 * @author <mail@tgries.de>
23 * @author Tim Starling
24 */
25
26
27 /**
28 * Stores a single person's name and email address.
29 * These are passed in via the constructor, and will be returned in SMTP
30 * header format when requested.
31 */
32 class MailAddress {
33 /**
34 * @param $address Mixed: string with an email address, or a User object
35 * @param $name String: human-readable name if a string address is given
36 * @param $realName String: human-readable real name if a string address is given
37 */
38 function __construct( $address, $name = null, $realName = null ) {
39 if ( is_object( $address ) && $address instanceof User ) {
40 $this->address = $address->getEmail();
41 $this->name = $address->getName();
42 $this->realName = $address->getRealName();
43 } else {
44 $this->address = strval( $address );
45 $this->name = strval( $name );
46 $this->realName = strval( $realName );
47 }
48 }
49
50 /**
51 * Return formatted and quoted address to insert into SMTP headers
52 * @return string
53 */
54 function toString() {
55 # PHP's mail() implementation under Windows is somewhat shite, and
56 # can't handle "Joe Bloggs <joe@bloggs.com>" format email addresses,
57 # so don't bother generating them
58 if ( $this->name != '' && !wfIsWindows() ) {
59 global $wgEnotifUseRealName;
60 $name = ( $wgEnotifUseRealName && $this->realName ) ? $this->realName : $this->name;
61 $quoted = UserMailer::quotedPrintable( $name );
62 if ( strpos( $quoted, '.' ) !== false || strpos( $quoted, ',' ) !== false ) {
63 $quoted = '"' . $quoted . '"';
64 }
65 return "$quoted <{$this->address}>";
66 } else {
67 return $this->address;
68 }
69 }
70
71 function __toString() {
72 return $this->toString();
73 }
74 }
75
76
77 /**
78 * Collection of static functions for sending mail
79 */
80 class UserMailer {
81 static $mErrorString;
82
83 /**
84 * Send mail using a PEAR mailer
85 */
86 protected static function sendWithPear( $mailer, $dest, $headers, $body ) {
87 $mailResult = $mailer->send( $dest, $headers, $body );
88
89 # Based on the result return an error string,
90 if ( PEAR::isError( $mailResult ) ) {
91 wfDebug( "PEAR::Mail failed: " . $mailResult->getMessage() . "\n" );
92 return Status::newFatal( 'pear-mail-error', $mailResult->getMessage() );
93 } else {
94 return Status::newGood();
95 }
96 }
97
98 /**
99 * This function will perform a direct (authenticated) login to
100 * a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
101 * array of parameters. It requires PEAR:Mail to do that.
102 * Otherwise it just uses the standard PHP 'mail' function.
103 *
104 * @param $to MailAddress: recipient's email (or an array of them)
105 * @param $from MailAddress: sender's email
106 * @param $subject String: email's subject.
107 * @param $body String: email's text.
108 * @param $replyto MailAddress: optional reply-to email (default: null).
109 * @param $contentType String: optional custom Content-Type (default: text/plain; charset=UTF-8)
110 * @return Status object
111 */
112 public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8') {
113 global $wgSMTP, $wgEnotifImpersonal;
114 global $wgEnotifMaxRecips, $wgAdditionalMailParams;
115
116 if ( is_array( $to ) ) {
117 $emails = '';
118 // This wouldn't be necessary if implode() worked on arrays of
119 // objects using __toString(). http://bugs.php.net/bug.php?id=36612
120 foreach ( $to as $t ) {
121 $emails .= $t->toString() . ",";
122 }
123 $emails = rtrim( $emails, ',' );
124 wfDebug( __METHOD__ . ': sending mail to ' . $emails . "\n" );
125 } else {
126 wfDebug( __METHOD__ . ': sending mail to ' . implode( ',', array( $to->toString() ) ) . "\n" );
127 }
128
129 if ( is_array( $wgSMTP ) ) {
130 if ( function_exists( 'stream_resolve_include_path' ) ) {
131 $found = stream_resolve_include_path( 'Mail.php' );
132 } else {
133 $found = Fallback::stream_resolve_include_path( 'Mail.php' );
134 }
135 if ( !$found ) {
136 throw new MWException( 'PEAR mail package is not installed' );
137 }
138 require_once( 'Mail.php' );
139
140 $msgid = str_replace( " ", "_", microtime() );
141 if ( function_exists( 'posix_getpid' ) )
142 $msgid .= '.' . posix_getpid();
143
144 if ( is_array( $to ) ) {
145 $dest = array();
146 foreach ( $to as $u )
147 $dest[] = $u->address;
148 } else
149 $dest = $to->address;
150
151 $headers['From'] = $from->toString();
152
153 if ( $wgEnotifImpersonal ) {
154 $headers['To'] = 'undisclosed-recipients:;';
155 }
156 else {
157 $headers['To'] = implode( ", ", (array )$dest );
158 }
159
160 if ( $replyto ) {
161 $headers['Reply-To'] = $replyto->toString();
162 }
163 $headers['Subject'] = self::quotedPrintable( $subject );
164 $headers['Date'] = date( 'r' );
165 $headers['MIME-Version'] = '1.0';
166 $headers['Content-type'] = ( is_null( $contentType ) ?
167 'text/plain; charset=UTF-8' : $contentType );
168 $headers['Content-transfer-encoding'] = '8bit';
169 // @todo FIXME
170 $headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>';
171 $headers['X-Mailer'] = 'MediaWiki mailer';
172
173 wfSuppressWarnings();
174
175 // Create the mail object using the Mail::factory method
176 $mail_object =& Mail::factory( 'smtp', $wgSMTP );
177 if ( PEAR::isError( $mail_object ) ) {
178 wfDebug( "PEAR::Mail factory failed: " . $mail_object->getMessage() . "\n" );
179 wfRestoreWarnings();
180 return Status::newFatal( 'pear-mail-error', $mail_object->getMessage() );
181 }
182
183 wfDebug( "Sending mail via PEAR::Mail to $dest\n" );
184 $chunks = array_chunk( (array)$dest, $wgEnotifMaxRecips );
185 foreach ( $chunks as $chunk ) {
186 $status = self::sendWithPear( $mail_object, $chunk, $headers, $body );
187 if ( !$status->isOK() ) {
188 wfRestoreWarnings();
189 return $status;
190 }
191 }
192 wfRestoreWarnings();
193 return Status::newGood();
194 } else {
195 # Line endings need to be different on Unix and Windows due to
196 # the bug described at http://trac.wordpress.org/ticket/2603
197 if ( wfIsWindows() ) {
198 $body = str_replace( "\n", "\r\n", $body );
199 $endl = "\r\n";
200 } else {
201 $endl = "\n";
202 }
203
204 $headers = array(
205 "MIME-Version: 1.0",
206 "Content-type: $contentType",
207 "Content-Transfer-Encoding: 8bit",
208 "X-Mailer: MediaWiki mailer",
209 "From: " . $from->toString(),
210 );
211 if ( $replyto ) {
212 $headers[] = "Reply-To: " . $replyto->toString();
213 }
214
215 $headers = implode( $endl, $headers );
216
217 wfDebug( "Sending mail via internal mail() function\n" );
218
219 self::$mErrorString = '';
220 $html_errors = ini_get( 'html_errors' );
221 ini_set( 'html_errors', '0' );
222 set_error_handler( array( 'UserMailer', 'errorHandler' ) );
223
224 if ( !is_array( $to ) ) {
225 $to = array( $to );
226 }
227 foreach ( $to as $recip ) {
228 $sent = mail( $recip->toString(), self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
229 }
230
231 restore_error_handler();
232 ini_set( 'html_errors', $html_errors );
233
234 if ( self::$mErrorString ) {
235 wfDebug( "Error sending mail: " . self::$mErrorString . "\n" );
236 return Status::newFatal( 'php-mail-error', self::$mErrorString );
237 } elseif ( ! $sent ) {
238 // mail function only tells if there's an error
239 wfDebug( "Error sending mail\n" );
240 return Status::newFatal( 'php-mail-error-unknown' );
241 } else {
242 return Status::newGood();
243 }
244 }
245 }
246
247 /**
248 * Set the mail error message in self::$mErrorString
249 *
250 * @param $code Integer: error number
251 * @param $string String: error message
252 */
253 static function errorHandler( $code, $string ) {
254 self::$mErrorString = preg_replace( '/^mail\(\)(\s*\[.*?\])?: /', '', $string );
255 }
256
257 /**
258 * Converts a string into a valid RFC 822 "phrase", such as is used for the sender name
259 */
260 public static function rfc822Phrase( $phrase ) {
261 $phrase = strtr( $phrase, array( "\r" => '', "\n" => '', '"' => '' ) );
262 return '"' . $phrase . '"';
263 }
264
265 /**
266 * Converts a string into quoted-printable format
267 * @since 1.17
268 */
269 public static function quotedPrintable( $string, $charset = '' ) {
270 # Probably incomplete; see RFC 2045
271 if( empty( $charset ) ) {
272 $charset = 'UTF-8';
273 }
274 $charset = strtoupper( $charset );
275 $charset = str_replace( 'ISO-8859', 'ISO8859', $charset ); // ?
276
277 $illegal = '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff=';
278 $replace = $illegal . '\t ?_';
279 if( !preg_match( "/[$illegal]/", $string ) ) {
280 return $string;
281 }
282 $out = "=?$charset?Q?";
283 $out .= preg_replace_callback( "/([$replace])/",
284 array( __CLASS__, 'quotedPrintableCallback' ), $string );
285 $out .= '?=';
286 return $out;
287 }
288
289 protected static function quotedPrintableCallback( $matches ) {
290 return sprintf( "=%02X", ord( $matches[1] ) );
291 }
292 }
293
294 /**
295 * This module processes the email notifications when the current page is
296 * changed. It looks up the table watchlist to find out which users are watching
297 * that page.
298 *
299 * The current implementation sends independent emails to each watching user for
300 * the following reason:
301 *
302 * - Each watching user will be notified about the page edit time expressed in
303 * his/her local time (UTC is shown additionally). To achieve this, we need to
304 * find the individual timeoffset of each watching user from the preferences..
305 *
306 * Suggested improvement to slack down the number of sent emails: We could think
307 * of sending out bulk mails (bcc:user1,user2...) for all these users having the
308 * same timeoffset in their preferences.
309 *
310 * Visit the documentation pages under http://meta.wikipedia.com/Enotif
311 *
312 *
313 */
314 class EmailNotification {
315 protected $to, $subject, $body, $replyto, $from;
316 protected $user, $title, $timestamp, $summary, $minorEdit, $oldid, $composed_common, $editor;
317 protected $mailTargets = array();
318
319 /**
320 * Send emails corresponding to the user $editor editing the page $title.
321 * Also updates wl_notificationtimestamp.
322 *
323 * May be deferred via the job queue.
324 *
325 * @param $editor User object
326 * @param $title Title object
327 * @param $timestamp
328 * @param $summary
329 * @param $minorEdit
330 * @param $oldid (default: false)
331 */
332 public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false ) {
333 global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker;
334
335 if ( $title->getNamespace() < 0 )
336 return;
337
338 // Build a list of users to notfiy
339 $watchers = array();
340 if ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) {
341 $dbw = wfGetDB( DB_MASTER );
342 $res = $dbw->select( array( 'watchlist' ),
343 array( 'wl_user' ),
344 array(
345 'wl_title' => $title->getDBkey(),
346 'wl_namespace' => $title->getNamespace(),
347 'wl_user != ' . intval( $editor->getID() ),
348 'wl_notificationtimestamp IS NULL',
349 ), __METHOD__
350 );
351 foreach ( $res as $row ) {
352 $watchers[] = intval( $row->wl_user );
353 }
354 if ( $watchers ) {
355 // Update wl_notificationtimestamp for all watching users except
356 // the editor
357 $dbw->begin();
358 $dbw->update( 'watchlist',
359 array( /* SET */
360 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
361 ), array( /* WHERE */
362 'wl_title' => $title->getDBkey(),
363 'wl_namespace' => $title->getNamespace(),
364 'wl_user' => $watchers
365 ), __METHOD__
366 );
367 $dbw->commit();
368 }
369 }
370
371 if ( $wgEnotifUseJobQ ) {
372 $params = array(
373 "editor" => $editor->getName(),
374 "editorID" => $editor->getID(),
375 "timestamp" => $timestamp,
376 "summary" => $summary,
377 "minorEdit" => $minorEdit,
378 "oldid" => $oldid,
379 "watchers" => $watchers );
380 $job = new EnotifNotifyJob( $title, $params );
381 $job->insert();
382 } else {
383 $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers );
384 }
385
386 }
387
388 /*
389 * Immediate version of notifyOnPageChange().
390 *
391 * Send emails corresponding to the user $editor editing the page $title.
392 * Also updates wl_notificationtimestamp.
393 *
394 * @param $editor User object
395 * @param $title Title object
396 * @param $timestamp string Edit timestamp
397 * @param $summary string Edit summary
398 * @param $minorEdit bool
399 * @param $oldid int Revision ID
400 * @param $watchers array of user IDs
401 */
402 public function actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers ) {
403 # we use $wgPasswordSender as sender's address
404 global $wgEnotifWatchlist;
405 global $wgEnotifMinorEdits, $wgEnotifUserTalk;
406
407 wfProfileIn( __METHOD__ );
408
409 # The following code is only run, if several conditions are met:
410 # 1. EmailNotification for pages (other than user_talk pages) must be enabled
411 # 2. minor edits (changes) are only regarded if the global flag indicates so
412
413 $isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK );
414
415 $this->title = $title;
416 $this->timestamp = $timestamp;
417 $this->summary = $summary;
418 $this->minorEdit = $minorEdit;
419 $this->oldid = $oldid;
420 $this->editor = $editor;
421 $this->composed_common = false;
422
423 $userTalkId = false;
424
425 if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) {
426 if ( $wgEnotifUserTalk && $isUserTalkPage ) {
427 $targetUser = User::newFromName( $title->getText() );
428 if ( !$targetUser || $targetUser->isAnon() ) {
429 wfDebug( __METHOD__ . ": user talk page edited, but user does not exist\n" );
430 } elseif ( $targetUser->getId() == $editor->getId() ) {
431 wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent\n" );
432 } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) ) {
433 if ( $targetUser->isEmailConfirmed() ) {
434 wfDebug( __METHOD__ . ": sending talk page update notification\n" );
435 $this->compose( $targetUser );
436 $userTalkId = $targetUser->getId();
437 } else {
438 wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" );
439 }
440 } else {
441 wfDebug( __METHOD__ . ": talk page owner doesn't want notifications\n" );
442 }
443 }
444
445 if ( $wgEnotifWatchlist ) {
446 // Send updates to watchers other than the current editor
447 $userArray = UserArray::newFromIDs( $watchers );
448 foreach ( $userArray as $watchingUser ) {
449 if ( $watchingUser->getOption( 'enotifwatchlistpages' ) &&
450 ( !$minorEdit || $watchingUser->getOption( 'enotifminoredits' ) ) &&
451 $watchingUser->isEmailConfirmed() &&
452 $watchingUser->getID() != $userTalkId )
453 {
454 $this->compose( $watchingUser );
455 }
456 }
457 }
458 }
459
460 global $wgUsersNotifiedOnAllChanges;
461 foreach ( $wgUsersNotifiedOnAllChanges as $name ) {
462 $user = User::newFromName( $name );
463 $this->compose( $user );
464 }
465
466 $this->sendMails();
467 wfProfileOut( __METHOD__ );
468 }
469
470 /**
471 * Generate the generic "this page has been changed" e-mail text.
472 */
473 private function composeCommonMailtext() {
474 global $wgPasswordSender, $wgPasswordSenderName, $wgNoReplyAddress;
475 global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
476 global $wgEnotifImpersonal, $wgEnotifUseRealName;
477
478 $this->composed_common = true;
479
480 $summary = ( $this->summary == '' ) ? ' - ' : $this->summary;
481 $medit = ( $this->minorEdit ) ? wfMsgForContent( 'minoredit' ) : '';
482
483 # You as the WikiAdmin and Sysops can make use of plenty of
484 # named variables when composing your notification emails while
485 # simply editing the Meta pages
486
487 $subject = wfMsgForContent( 'enotif_subject' );
488 $body = wfMsgForContent( 'enotif_body' );
489 $from = ''; /* fail safe */
490 $replyto = ''; /* fail safe */
491 $keys = array();
492
493 if ( $this->oldid ) {
494 $difflink = $this->title->getFullUrl( 'diff=0&oldid=' . $this->oldid );
495 $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastvisited', $difflink );
496 $keys['$OLDID'] = $this->oldid;
497 $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'changed' );
498 } else {
499 $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_newpagetext' );
500 # clear $OLDID placeholder in the message template
501 $keys['$OLDID'] = '';
502 $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' );
503 }
504
505 if ( $wgEnotifImpersonal && $this->oldid ) {
506 /*
507 * For impersonal mail, show a diff link to the last
508 * revision.
509 */
510 $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff',
511 $this->title->getFullURL( "oldid={$this->oldid}&diff=next" ) );
512 }
513
514 $body = strtr( $body, $keys );
515 $pagetitle = $this->title->getPrefixedText();
516 $keys['$PAGETITLE'] = $pagetitle;
517 $keys['$PAGETITLE_URL'] = $this->title->getFullUrl();
518
519 $keys['$PAGEMINOREDIT'] = $medit;
520 $keys['$PAGESUMMARY'] = $summary;
521 $keys['$UNWATCHURL'] = $this->title->getFullUrl( 'action=unwatch' );
522
523 $subject = strtr( $subject, $keys );
524
525 # Reveal the page editor's address as REPLY-TO address only if
526 # the user has not opted-out and the option is enabled at the
527 # global configuration level.
528 $editor = $this->editor;
529 $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
530 $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
531 $editorAddress = new MailAddress( $editor );
532 if ( $wgEnotifRevealEditorAddress
533 && ( $editor->getEmail() != '' )
534 && $editor->getOption( 'enotifrevealaddr' ) ) {
535 if ( $wgEnotifFromEditor ) {
536 $from = $editorAddress;
537 } else {
538 $from = $adminAddress;
539 $replyto = $editorAddress;
540 }
541 } else {
542 $from = $adminAddress;
543 $replyto = new MailAddress( $wgNoReplyAddress );
544 }
545
546 if ( $editor->isIP( $name ) ) {
547 # real anon (user:xxx.xxx.xxx.xxx)
548 $utext = wfMsgForContent( 'enotif_anon_editor', $name );
549 $subject = str_replace( '$PAGEEDITOR', $utext, $subject );
550 $keys['$PAGEEDITOR'] = $utext;
551 $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' );
552 } else {
553 $subject = str_replace( '$PAGEEDITOR', $name, $subject );
554 $keys['$PAGEEDITOR'] = $name;
555 $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name );
556 $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getFullUrl();
557 }
558 $userPage = $editor->getUserPage();
559 $keys['$PAGEEDITOR_WIKI'] = $userPage->getFullUrl();
560 $body = strtr( $body, $keys );
561 $body = wordwrap( $body, 72 );
562
563 # now save this as the constant user-independent part of the message
564 $this->from = $from;
565 $this->replyto = $replyto;
566 $this->subject = $subject;
567 $this->body = $body;
568 }
569
570 /**
571 * Compose a mail to a given user and either queue it for sending, or send it now,
572 * depending on settings.
573 *
574 * Call sendMails() to send any mails that were queued.
575 */
576 function compose( $user ) {
577 global $wgEnotifImpersonal;
578
579 if ( !$this->composed_common )
580 $this->composeCommonMailtext();
581
582 if ( $wgEnotifImpersonal ) {
583 $this->mailTargets[] = new MailAddress( $user );
584 } else {
585 $this->sendPersonalised( $user );
586 }
587 }
588
589 /**
590 * Send any queued mails
591 */
592 function sendMails() {
593 global $wgEnotifImpersonal;
594 if ( $wgEnotifImpersonal ) {
595 $this->sendImpersonal( $this->mailTargets );
596 }
597 }
598
599 /**
600 * Does the per-user customizations to a notification e-mail (name,
601 * timestamp in proper timezone, etc) and sends it out.
602 * Returns true if the mail was sent successfully.
603 *
604 * @param $watchingUser User object
605 * @return Boolean
606 * @private
607 */
608 function sendPersonalised( $watchingUser ) {
609 global $wgContLang, $wgEnotifUseRealName;
610 // From the PHP manual:
611 // Note: The to parameter cannot be an address in the form of "Something <someone@example.com>".
612 // The mail command will not parse this properly while talking with the MTA.
613 $to = new MailAddress( $watchingUser );
614 $name = $wgEnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName();
615 $body = str_replace( '$WATCHINGUSERNAME', $name, $this->body );
616
617 $timecorrection = $watchingUser->getOption( 'timecorrection' );
618
619 # $PAGEEDITDATE is the time and date of the page change
620 # expressed in terms of individual local time of the notification
621 # recipient, i.e. watching user
622 $body = str_replace(
623 array( '$PAGEEDITDATEANDTIME',
624 '$PAGEEDITDATE',
625 '$PAGEEDITTIME' ),
626 array( $wgContLang->timeanddate( $this->timestamp, true, false, $timecorrection ),
627 $wgContLang->date( $this->timestamp, true, false, $timecorrection ),
628 $wgContLang->time( $this->timestamp, true, false, $timecorrection ) ),
629 $body );
630
631 return UserMailer::send( $to, $this->from, $this->subject, $body, $this->replyto );
632 }
633
634 /**
635 * Same as sendPersonalised but does impersonal mail suitable for bulk
636 * mailing. Takes an array of MailAddress objects.
637 */
638 function sendImpersonal( $addresses ) {
639 global $wgContLang;
640
641 if ( empty( $addresses ) )
642 return;
643
644 $body = str_replace(
645 array( '$WATCHINGUSERNAME',
646 '$PAGEEDITDATE' ),
647 array( wfMsgForContent( 'enotif_impersonal_salutation' ),
648 $wgContLang->timeanddate( $this->timestamp, true, false, false ) ),
649 $this->body );
650
651 return UserMailer::send( $addresses, $this->from, $this->subject, $body, $this->replyto );
652 }
653
654 } # end of class EmailNotification