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