Move wfQuotedPrintable() into UserMailer class
[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 */
271 public static function quotedPrintable( $string, $charset = '' ) {
272 # Probably incomplete; see RFC 2045
273 if( empty( $charset ) ) {
274 global $wgInputEncoding;
275 $charset = $wgInputEncoding;
276 }
277 $charset = strtoupper( $charset );
278 $charset = str_replace( 'ISO-8859', 'ISO8859', $charset ); // ?
279
280 $illegal = '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff=';
281 $replace = $illegal . '\t ?_';
282 if( !preg_match( "/[$illegal]/", $string ) ) {
283 return $string;
284 }
285 $out = "=?$charset?Q?";
286 $out .= preg_replace( "/([$replace])/e", 'sprintf("=%02X",ord("$1"))', $string );
287 $out .= '?=';
288 return $out;
289 }
290 }
291
292 /**
293 * This module processes the email notifications when the current page is
294 * changed. It looks up the table watchlist to find out which users are watching
295 * that page.
296 *
297 * The current implementation sends independent emails to each watching user for
298 * the following reason:
299 *
300 * - Each watching user will be notified about the page edit time expressed in
301 * his/her local time (UTC is shown additionally). To achieve this, we need to
302 * find the individual timeoffset of each watching user from the preferences..
303 *
304 * Suggested improvement to slack down the number of sent emails: We could think
305 * of sending out bulk mails (bcc:user1,user2...) for all these users having the
306 * same timeoffset in their preferences.
307 *
308 * Visit the documentation pages under http://meta.wikipedia.com/Enotif
309 *
310 *
311 */
312 class EmailNotification {
313 protected $to, $subject, $body, $replyto, $from;
314 protected $user, $title, $timestamp, $summary, $minorEdit, $oldid, $composed_common, $editor;
315 protected $mailTargets = array();
316
317 /**
318 * Send emails corresponding to the user $editor editing the page $title.
319 * Also updates wl_notificationtimestamp.
320 *
321 * May be deferred via the job queue.
322 *
323 * @param $editor User object
324 * @param $title Title object
325 * @param $timestamp
326 * @param $summary
327 * @param $minorEdit
328 * @param $oldid (default: false)
329 */
330 public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false ) {
331 global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker;
332
333 if ( $title->getNamespace() < 0 )
334 return;
335
336 // Build a list of users to notfiy
337 $watchers = array();
338 if ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) {
339 $dbw = wfGetDB( DB_MASTER );
340 $res = $dbw->select( array( 'watchlist' ),
341 array( 'wl_user' ),
342 array(
343 'wl_title' => $title->getDBkey(),
344 'wl_namespace' => $title->getNamespace(),
345 'wl_user != ' . intval( $editor->getID() ),
346 'wl_notificationtimestamp IS NULL',
347 ), __METHOD__
348 );
349 foreach ( $res as $row ) {
350 $watchers[] = intval( $row->wl_user );
351 }
352 if ( $watchers ) {
353 // Update wl_notificationtimestamp for all watching users except
354 // the editor
355 $dbw->begin();
356 $dbw->update( 'watchlist',
357 array( /* SET */
358 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
359 ), array( /* WHERE */
360 'wl_title' => $title->getDBkey(),
361 'wl_namespace' => $title->getNamespace(),
362 'wl_user' => $watchers
363 ), __METHOD__
364 );
365 $dbw->commit();
366 }
367 }
368
369 if ( $wgEnotifUseJobQ ) {
370 $params = array(
371 "editor" => $editor->getName(),
372 "editorID" => $editor->getID(),
373 "timestamp" => $timestamp,
374 "summary" => $summary,
375 "minorEdit" => $minorEdit,
376 "oldid" => $oldid,
377 "watchers" => $watchers );
378 $job = new EnotifNotifyJob( $title, $params );
379 $job->insert();
380 } else {
381 $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers );
382 }
383
384 }
385
386 /*
387 * Immediate version of notifyOnPageChange().
388 *
389 * Send emails corresponding to the user $editor editing the page $title.
390 * Also updates wl_notificationtimestamp.
391 *
392 * @param $editor User object
393 * @param $title Title object
394 * @param $timestamp string Edit timestamp
395 * @param $summary string Edit summary
396 * @param $minorEdit bool
397 * @param $oldid int Revision ID
398 * @param $watchers array of user IDs
399 */
400 public function actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers ) {
401 # we use $wgPasswordSender as sender's address
402 global $wgEnotifWatchlist;
403 global $wgEnotifMinorEdits, $wgEnotifUserTalk;
404
405 wfProfileIn( __METHOD__ );
406
407 # The following code is only run, if several conditions are met:
408 # 1. EmailNotification for pages (other than user_talk pages) must be enabled
409 # 2. minor edits (changes) are only regarded if the global flag indicates so
410
411 $isUserTalkPage = ( $title->getNamespace() == NS_USER_TALK );
412
413 $this->title = $title;
414 $this->timestamp = $timestamp;
415 $this->summary = $summary;
416 $this->minorEdit = $minorEdit;
417 $this->oldid = $oldid;
418 $this->editor = $editor;
419 $this->composed_common = false;
420
421 $userTalkId = false;
422
423 if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) {
424 if ( $wgEnotifUserTalk && $isUserTalkPage ) {
425 $targetUser = User::newFromName( $title->getText() );
426 if ( !$targetUser || $targetUser->isAnon() ) {
427 wfDebug( __METHOD__ . ": user talk page edited, but user does not exist\n" );
428 } elseif ( $targetUser->getId() == $editor->getId() ) {
429 wfDebug( __METHOD__ . ": user edited their own talk page, no notification sent\n" );
430 } elseif ( $targetUser->getOption( 'enotifusertalkpages' ) ) {
431 if ( $targetUser->isEmailConfirmed() ) {
432 wfDebug( __METHOD__ . ": sending talk page update notification\n" );
433 $this->compose( $targetUser );
434 $userTalkId = $targetUser->getId();
435 } else {
436 wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" );
437 }
438 } else {
439 wfDebug( __METHOD__ . ": talk page owner doesn't want notifications\n" );
440 }
441 }
442
443 if ( $wgEnotifWatchlist ) {
444 // Send updates to watchers other than the current editor
445 $userArray = UserArray::newFromIDs( $watchers );
446 foreach ( $userArray as $watchingUser ) {
447 if ( $watchingUser->getOption( 'enotifwatchlistpages' ) &&
448 ( !$minorEdit || $watchingUser->getOption( 'enotifminoredits' ) ) &&
449 $watchingUser->isEmailConfirmed() &&
450 $watchingUser->getID() != $userTalkId )
451 {
452 $this->compose( $watchingUser );
453 }
454 }
455 }
456 }
457
458 global $wgUsersNotifiedOnAllChanges;
459 foreach ( $wgUsersNotifiedOnAllChanges as $name ) {
460 $user = User::newFromName( $name );
461 $this->compose( $user );
462 }
463
464 $this->sendMails();
465 wfProfileOut( __METHOD__ );
466 }
467
468 /**
469 * Generate the generic "this page has been changed" e-mail text.
470 */
471 private function composeCommonMailtext() {
472 global $wgPasswordSender, $wgPasswordSenderName, $wgNoReplyAddress;
473 global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
474 global $wgEnotifImpersonal, $wgEnotifUseRealName;
475
476 $this->composed_common = true;
477
478 $summary = ( $this->summary == '' ) ? ' - ' : $this->summary;
479 $medit = ( $this->minorEdit ) ? wfMsgForContent( 'minoredit' ) : '';
480
481 # You as the WikiAdmin and Sysops can make use of plenty of
482 # named variables when composing your notification emails while
483 # simply editing the Meta pages
484
485 $subject = wfMsgForContent( 'enotif_subject' );
486 $body = wfMsgForContent( 'enotif_body' );
487 $from = ''; /* fail safe */
488 $replyto = ''; /* fail safe */
489 $keys = array();
490
491 if ( $this->oldid ) {
492 $difflink = $this->title->getFullUrl( 'diff=0&oldid=' . $this->oldid );
493 $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastvisited', $difflink );
494 $keys['$OLDID'] = $this->oldid;
495 $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'changed' );
496 } else {
497 $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_newpagetext' );
498 # clear $OLDID placeholder in the message template
499 $keys['$OLDID'] = '';
500 $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' );
501 }
502
503 if ( $wgEnotifImpersonal && $this->oldid ) {
504 /*
505 * For impersonal mail, show a diff link to the last
506 * revision.
507 */
508 $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff',
509 $this->title->getFullURL( "oldid={$this->oldid}&diff=next" ) );
510 }
511
512 $body = strtr( $body, $keys );
513 $pagetitle = $this->title->getPrefixedText();
514 $keys['$PAGETITLE'] = $pagetitle;
515 $keys['$PAGETITLE_URL'] = $this->title->getFullUrl();
516
517 $keys['$PAGEMINOREDIT'] = $medit;
518 $keys['$PAGESUMMARY'] = $summary;
519 $keys['$UNWATCHURL'] = $this->title->getFullUrl( 'action=unwatch' );
520
521 $subject = strtr( $subject, $keys );
522
523 # Reveal the page editor's address as REPLY-TO address only if
524 # the user has not opted-out and the option is enabled at the
525 # global configuration level.
526 $editor = $this->editor;
527 $name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
528 $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
529 $editorAddress = new MailAddress( $editor );
530 if ( $wgEnotifRevealEditorAddress
531 && ( $editor->getEmail() != '' )
532 && $editor->getOption( 'enotifrevealaddr' ) ) {
533 if ( $wgEnotifFromEditor ) {
534 $from = $editorAddress;
535 } else {
536 $from = $adminAddress;
537 $replyto = $editorAddress;
538 }
539 } else {
540 $from = $adminAddress;
541 $replyto = new MailAddress( $wgNoReplyAddress );
542 }
543
544 if ( $editor->isIP( $name ) ) {
545 # real anon (user:xxx.xxx.xxx.xxx)
546 $utext = wfMsgForContent( 'enotif_anon_editor', $name );
547 $subject = str_replace( '$PAGEEDITOR', $utext, $subject );
548 $keys['$PAGEEDITOR'] = $utext;
549 $keys['$PAGEEDITOR_EMAIL'] = wfMsgForContent( 'noemailtitle' );
550 } else {
551 $subject = str_replace( '$PAGEEDITOR', $name, $subject );
552 $keys['$PAGEEDITOR'] = $name;
553 $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name );
554 $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getFullUrl();
555 }
556 $userPage = $editor->getUserPage();
557 $keys['$PAGEEDITOR_WIKI'] = $userPage->getFullUrl();
558 $body = strtr( $body, $keys );
559 $body = wordwrap( $body, 72 );
560
561 # now save this as the constant user-independent part of the message
562 $this->from = $from;
563 $this->replyto = $replyto;
564 $this->subject = $subject;
565 $this->body = $body;
566 }
567
568 /**
569 * Compose a mail to a given user and either queue it for sending, or send it now,
570 * depending on settings.
571 *
572 * Call sendMails() to send any mails that were queued.
573 */
574 function compose( $user ) {
575 global $wgEnotifImpersonal;
576
577 if ( !$this->composed_common )
578 $this->composeCommonMailtext();
579
580 if ( $wgEnotifImpersonal ) {
581 $this->mailTargets[] = new MailAddress( $user );
582 } else {
583 $this->sendPersonalised( $user );
584 }
585 }
586
587 /**
588 * Send any queued mails
589 */
590 function sendMails() {
591 global $wgEnotifImpersonal;
592 if ( $wgEnotifImpersonal ) {
593 $this->sendImpersonal( $this->mailTargets );
594 }
595 }
596
597 /**
598 * Does the per-user customizations to a notification e-mail (name,
599 * timestamp in proper timezone, etc) and sends it out.
600 * Returns true if the mail was sent successfully.
601 *
602 * @param $watchingUser User object
603 * @return Boolean
604 * @private
605 */
606 function sendPersonalised( $watchingUser ) {
607 global $wgContLang, $wgEnotifUseRealName;
608 // From the PHP manual:
609 // Note: The to parameter cannot be an address in the form of "Something <someone@example.com>".
610 // The mail command will not parse this properly while talking with the MTA.
611 $to = new MailAddress( $watchingUser );
612 $name = $wgEnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName();
613 $body = str_replace( '$WATCHINGUSERNAME', $name, $this->body );
614
615 $timecorrection = $watchingUser->getOption( 'timecorrection' );
616
617 # $PAGEEDITDATE is the time and date of the page change
618 # expressed in terms of individual local time of the notification
619 # recipient, i.e. watching user
620 $body = str_replace(
621 array( '$PAGEEDITDATEANDTIME',
622 '$PAGEEDITDATE',
623 '$PAGEEDITTIME' ),
624 array( $wgContLang->timeanddate( $this->timestamp, true, false, $timecorrection ),
625 $wgContLang->date( $this->timestamp, true, false, $timecorrection ),
626 $wgContLang->time( $this->timestamp, true, false, $timecorrection ) ),
627 $body );
628
629 return UserMailer::send( $to, $this->from, $this->subject, $body, $this->replyto );
630 }
631
632 /**
633 * Same as sendPersonalised but does impersonal mail suitable for bulk
634 * mailing. Takes an array of MailAddress objects.
635 */
636 function sendImpersonal( $addresses ) {
637 global $wgContLang;
638
639 if ( empty( $addresses ) )
640 return;
641
642 $body = str_replace(
643 array( '$WATCHINGUSERNAME',
644 '$PAGEEDITDATE' ),
645 array( wfMsgForContent( 'enotif_impersonal_salutation' ),
646 $wgContLang->timeanddate( $this->timestamp, true, false, false ) ),
647 $this->body );
648
649 return UserMailer::send( $addresses, $this->from, $this->subject, $body, $this->replyto );
650 }
651
652 } # end of class EmailNotification
653
654 /**@{
655 * Backwards compatibility functions
656 *
657 * @deprecated Use UserMailer methods; will be removed in 1.19
658 */
659 function wfRFC822Phrase( $s ) {
660 wfDeprecated( __FUNCTION__ );
661 return UserMailer::rfc822Phrase( $s );
662 }
663
664 function userMailer( $to, $from, $subject, $body, $replyto = null ) {
665 wfDeprecated( __FUNCTION__ );
666 return UserMailer::send( $to, $from, $subject, $body, $replyto );
667 }
668
669 function wfQuotedPrintable( $string, $charset = '' ) {
670 wfDeprecated( __FUNCTION__ );
671 return UserMailer::quotedPrintable( $string, $charset );
672 }
673 /**@}*/