New global config setting $wgMaxTocLevel: Maximum indent level of toc.
[lhc/web/wiklou.git] / includes / UserMailer.php
index 5a82988..6704a82 100644 (file)
@@ -1,4 +1,4 @@
-<?
+<?php
 
 # This function will perform a direct (authenticated) login to
 # a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
@@ -6,18 +6,20 @@
 # 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 );
        
        if (is_array( $wgSMTP ))
        {
-               include_once( "Mail.php" );
+               require_once( "Mail.php" );
                
                $timestamp = time();
        
                $headers["From"] = $from;
-               $headers["To"] = $qto;
+/* removing to: field as it should be set by the send() function below
+   UNTESTED - Hashar */
+//             $headers["To"] = $qto;
                $headers["Subject"] = $subject;
                $headers["MIME-Version"] = "1.0";
                $headers["Content-type"] = "text/plain; charset={$wgOutputEncoding}";
@@ -47,12 +49,20 @@ function userMailer( $to, $from, $subject, $body )
                        "Content-transfer-encoding: 8bit\r\n" .
                        "From: {$from}\r\n" .
                        "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 );
+}
+
+?>