error message returned even for non-PEAR function
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 1 Apr 2004 13:05:20 +0000 (13:05 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 1 Apr 2004 13:05:20 +0000 (13:05 +0000)
includes/UserMailer.php

index 155677b..f6097af 100644 (file)
@@ -6,7 +6,7 @@
 # Otherwise it just uses the standard PHP 'mail' function.
 function userMailer( $to, $from, $subject, $body )
 {
-       global $wgUser, $wgSMTP, $wgOutputEncoding;
+       global $wgUser, $wgSMTP, $wgOutputEncoding, $wgErrorString;
        
        $qto = wfQuotedPrintable( $to );
        
@@ -49,10 +49,19 @@ function userMailer( $to, $from, $subject, $body )
                        "Reply-To: {$from}\r\n" .
                        "To: {$qto}\r\n" .
                        "X-Mailer: MediaWiki interuser e-mailer";
+
+               $wgErrorString = "";
+               set_error_handler( "mailErrorHandler" );
                mail( $to, $subject, $body, $headers );
-               
-               return "";
+               restore_error_handler();
+
+               return $wgErrorString;
        }
 }
 
-?>
\ No newline at end of file
+function mailErrorHandler( $code, $string ) {
+       global $wgErrorString;
+       $wgErrorString = preg_replace( "/^mail\(\): /", "", $string );
+}
+
+?>