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