$wgEmergencyContact = "wikiadmin@" . getenv( "SERVER_NAME" );
$wgPasswordSender = "Wikipedia Mail <apache@" . getenv( "SERVER_NAME" ) . ">";
+# For using a direct (authenticated) SMTP server connection.
+# "host" => 'SMTP domain', "IDHost" => 'domain for MessageID', "port" => "25", "auth" => true/false, "username" => user, "password" => password
+$wgSMTP = false;
+
# MySQL settings
#
$wgDBserver = "localhost";
<?php
+require_once('UserMailer.php');
+
function wfSpecialEmailuser()
{
global $wgUser, $wgOut, $action, $target;
global $wpSubject, $wpText, $target;
$from = wfQuotedPrintable( $wgUser->getName() ) . " <" . $wgUser->getEmail() . ">";
- $to = wfQuotedPrintable( $this->mAddress );
-
- $headers =
- "MIME-Version: 1.0\r\n" .
- "Content-type: text/plain; charset={$wgOutputEncoding}\r\n" .
- "Content-transfer-encoding: 8bit\r\n" .
- "From: {$from}\r\n" .
- "Reply-To: {$from}\r\n" .
- "To: {$to}\r\n" .
- "X-Mailer: MediaWiki interuser e-mailer";
- mail( $this->mAddress, wfQuotedPrintable( $wpSubject ), $wpText, $headers );
-
-
- $success = wfLocalUrl( $wgLang->specialPage( "Emailuser" ),
- "target={$target}&action=success" );
- $wgOut->redirect( $success );
+
+ $mailResult = userMailer( $this->mAddress, $from, wfQuotedPrintable( $wpSubject ), $wpText );
+
+ if (! $mailResult)
+ {
+ $success = wfLocalUrl( $wgLang->specialPage( "Emailuser" ),
+ "target={$target}&action=success" );
+ $wgOut->redirect( $success );
+ }
+ else
+ $wgOut->addHTML( wfMsg( "usermailererror" ) . $mailResult);
}
function showSuccess()
<?php
+require_once('UserMailer.php');
+
function wfSpecialUserlogin()
{
global $wpCreateaccount, $wpCreateaccountMail;
$m = wfMsg( "passwordremindertext", $ip, $u->getName(), $np );
- mail( $u->getEmail(), wfMsg( "passwordremindertitle" ), $m,
- "MIME-Version: 1.0\r\n" .
- "Content-type: text/plain; charset={$wgOutputEncoding}\r\n" .
- "Content-transfer-encoding: 8bit\r\n" .
- "From: $wgPasswordSender" );
+ userMailer( $u->getEmail(), $wgPasswordSender, wfMsg( "passwordremindertitle" ), $m );
return $u;
}
--- /dev/null
+<?
+
+# This function will perform a direct (authenticated) login to
+# a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
+# array of parameters. It requires PEAR:Mail to do that.
+# Otherwise it just uses the standard PHP 'mail' function.
+function userMailer( $to, $from, $subject, $body )
+{
+ global $wgUser, $wgSMTP, $wgOutputEncoding;
+
+ $qto = wfQuotedPrintable( $to );
+
+ if (is_array( $wgSMTP ))
+ {
+ include_once( "Mail.php" );
+
+ $timestamp = time();
+
+ $headers["From"] = $from;
+ $headers["To"] = $qto;
+ $headers["Subject"] = $subject;
+ $headers["MIME-Version"] = "1.0";
+ $headers["Content-type"] = "text/plain; charset={$wgOutputEncoding}";
+ $headers["Content-transfer-encoding"] = "8bit";
+ $headers["Message-ID"] = "<{$timestamp}" . $wgUser->getName() . "@" . $wgSMTP["IDHost"] . ">";
+ $headers["X-Mailer"] = "MediaWiki interuser e-mailer";
+
+ // Create the mail object using the Mail::factory method
+ $mail_object =& Mail::factory("smtp", $wgSMTP);
+
+ $mailResult =& $mail_object->send($to, $headers, $body);
+
+ # Based on the result return an error string,
+ if ($mailResult === true)
+ return "";
+ else if (is_object($mailResult))
+ return $mailResult->getMessage();
+ else
+ return "Mail object return unknown error.";
+ }
+
+ else
+ {
+ $headers =
+ "MIME-Version: 1.0\r\n" .
+ "Content-type: text/plain; charset={$wgOutputEncoding}\r\n" .
+ "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";
+ mail( $to, $subject, $body, $headers );
+
+ return "";
+ }
+}
+
+?>
\ No newline at end of file