UserMailer.php 20 KB

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