-<?
+<?php
# This function will perform a direct (authenticated) login to
# a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
# 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}";
"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 );
+}
+
+?>