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