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