r24048 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24047‎ | r24048 | r24049 >
Date:21:16, 12 July 2007
Author:sanbeg
Status:old
Tags:
Comment:
Add error checking for mail() function
Modified paths:
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/UserMailer.php
@@ -180,19 +180,28 @@
181181 set_error_handler( 'mailErrorHandler' );
182182 wfDebug( "Sending mail via internal mail() function\n" );
183183
184 - if (is_array($to))
185 - foreach ($to as $recip)
186 - mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers );
 184+ if (function_exists('mail'))
 185+ if (is_array($to))
 186+ foreach ($to as $recip)
 187+ $sent = mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers );
 188+ else
 189+ $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers );
187190 else
188 - mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers );
 191+ $wgErrorString = 'PHP is not configured to send mail';
189192
 193+
190194 restore_error_handler();
191195
192196 if ( $wgErrorString ) {
193197 wfDebug( "Error sending mail: $wgErrorString\n" );
 198+ return $wgErrorString;
 199+ } elseif (! $sent) {
 200+ //mail function only tells if there's an error
 201+ wfDebug( "Error sending mail\n" );
 202+ return 'mailer error';
 203+ } else {
 204+ return '';
194205 }
195 - return $wgErrorString;
196 - }
197206 }
198207
199208 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r24096Merged revisions 23910-24094 via svnmerge from...david22:38, 14 July 2007

Status & tagging log