Index: trunk/phase3/includes/UserMailer.php |
— | — | @@ -75,6 +75,8 @@ |
76 | 76 | * Collection of static functions for sending mail |
77 | 77 | */ |
78 | 78 | class UserMailer { |
| 79 | + static $mErrorString; |
| 80 | + |
79 | 81 | /** |
80 | 82 | * Send mail using a PEAR mailer |
81 | 83 | */ |
— | — | @@ -106,7 +108,7 @@ |
107 | 109 | * @return mixed True on success, a WikiError object on failure. |
108 | 110 | */ |
109 | 111 | static function send( $to, $from, $subject, $body, $replyto=null, $contentType=null ) { |
110 | | - global $wgSMTP, $wgOutputEncoding, $wgErrorString, $wgEnotifImpersonal; |
| 112 | + global $wgSMTP, $wgOutputEncoding, $wgEnotifImpersonal; |
111 | 113 | global $wgEnotifMaxRecips; |
112 | 114 | |
113 | 115 | if ( is_array( $to ) ) { |
— | — | @@ -190,7 +192,7 @@ |
191 | 193 | |
192 | 194 | wfDebug( "Sending mail via internal mail() function\n" ); |
193 | 195 | |
194 | | - $wgErrorString = ''; |
| 196 | + self::$mErrorString = ''; |
195 | 197 | $html_errors = ini_get( 'html_errors' ); |
196 | 198 | ini_set( 'html_errors', '0' ); |
197 | 199 | set_error_handler( array( 'UserMailer', 'errorHandler' ) ); |
— | — | @@ -204,19 +206,19 @@ |
205 | 207 | $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers ); |
206 | 208 | } |
207 | 209 | } else { |
208 | | - $wgErrorString = 'PHP is not configured to send mail'; |
| 210 | + self::$mErrorString = 'PHP is not configured to send mail'; |
209 | 211 | } |
210 | 212 | |
211 | 213 | restore_error_handler(); |
212 | 214 | ini_set( 'html_errors', $html_errors ); |
213 | 215 | |
214 | | - if ( $wgErrorString ) { |
215 | | - wfDebug( "Error sending mail: $wgErrorString\n" ); |
216 | | - return new WikiError( $wgErrorString ); |
217 | | - } elseif (! $sent) { |
| 216 | + if ( self::$mErrorString ) { |
| 217 | + wfDebug( "Error sending mail: " . self::$mErrorString . "\n" ); |
| 218 | + return new WikiError( self::$mErrorString ); |
| 219 | + } elseif (! $sent ) { |
218 | 220 | //mail function only tells if there's an error |
219 | 221 | wfDebug( "Error sending mail\n" ); |
220 | | - return new WikiError( 'mailer error' ); |
| 222 | + return new WikiError( 'mail() failed' ); |
221 | 223 | } else { |
222 | 224 | return true; |
223 | 225 | } |
— | — | @@ -224,14 +226,13 @@ |
225 | 227 | } |
226 | 228 | |
227 | 229 | /** |
228 | | - * Get the mail error message in global $wgErrorString |
| 230 | + * Set the mail error message in self::$mErrorString |
229 | 231 | * |
230 | 232 | * @param $code Integer: error number |
231 | 233 | * @param $string String: error message |
232 | 234 | */ |
233 | 235 | static function errorHandler( $code, $string ) { |
234 | | - global $wgErrorString; |
235 | | - $wgErrorString = preg_replace( '/^mail\(\)(\s*\[.*?\])?: /', '', $string ); |
| 236 | + self::$mErrorString = preg_replace( '/^mail\(\)(\s*\[.*?\])?: /', '', $string ); |
236 | 237 | } |
237 | 238 | |
238 | 239 | /** |