* (bug 6243) Fix email for usernames containing dots when using PEAR::Mail
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 9 Jun 2006 08:24:47 +0000 (08:24 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 9 Jun 2006 08:24:47 +0000 (08:24 +0000)
RELEASE-NOTES
includes/SpecialConfirmemail.php
includes/UserMailer.php

index 814f328..e4caaf4 100644 (file)
@@ -461,6 +461,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 5981) Add plural function Slovenian (sl)
 * (bug 5945) Introduce {{CONTENTLANGUAGE}} magic word
 * {{PLURAL}} can now take up to five forms
+* (bug 6243) Fix email for usernames containing dots when using PEAR::Mail
+
 
 == Compatibility ==
 
index e07ed00..fd0425a 100644 (file)
@@ -49,7 +49,8 @@ class EmailConfirmation extends SpecialPage {
        function showRequestForm() {
                global $wgOut, $wgUser, $wgLang, $wgRequest;
                if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getText( 'token' ) ) ) {
-                       $message = $wgUser->sendConfirmationMail() ? 'confirmemail_sent' : 'confirmemail_sendfailed';
+                       $ok = $wgUser->sendConfirmationMail();
+                       $message = WikiError::isError( $ok ) ? 'confirmemail_sendfailed' : 'confirmemail_sent';
                        $wgOut->addWikiText( wfMsg( $message ) );
                } else {
                        if( $wgUser->isEmailConfirmed() ) {
index 5627146..8de39a6 100644 (file)
@@ -54,7 +54,11 @@ class MailAddress {
         */
        function toString() {
                if( $this->name != '' ) {
-                       return wfQuotedPrintable( $this->name ) . " <" . $this->address . ">";
+                       $quoted = wfQuotedPrintable( $this->name );
+                       if( strpos( $quoted, '.' ) !== false ) {
+                               $quoted = '"' . $quoted . '"';
+                       }
+                       return "$quoted <{$this->address}>";
                } else {
                        return $this->address;
                }
@@ -80,10 +84,10 @@ function userMailer( $to, $from, $subject, $body, $replyto=false ) {
                require_once( 'Mail.php' );
 
                $timestamp = time();
-               $dest = $to->toString();
+               $dest = $to->address;
 
                $headers['From'] = $from->toString();
-               $headers['To'] = $dest;
+               $headers['To'] = $to->toString();
                if ( $replyto ) {
                        $headers['Reply-To'] = $replyto;
                }
@@ -97,7 +101,7 @@ function userMailer( $to, $from, $subject, $body, $replyto=false ) {
 
                // Create the mail object using the Mail::factory method
                $mail_object =& Mail::factory('smtp', $wgSMTP);
-               wfDebug( "Sending mail via PEAR::Mail to $dest" );
+               wfDebug( "Sending mail via PEAR::Mail to $dest\n" );
                $mailResult =& $mail_object->send($dest, $headers, $body);
 
                # Based on the result return an error string,