further sanity checks for sending email … bomb out if we aren't given
authorMark A. Hershberger <mah@users.mediawiki.org>
Thu, 28 Jul 2011 19:15:58 +0000 (19:15 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Thu, 28 Jul 2011 19:15:58 +0000 (19:15 +0000)
any user with an email address.

includes/UserMailer.php
languages/messages/MessagesEn.php

index 47e95b2..1bb7c08 100644 (file)
@@ -67,6 +67,8 @@ class MailAddress {
                        } else {
                                return $this->address;
                        }
+               } else {
+                       return "";
                }
        }
 
@@ -153,6 +155,9 @@ class UserMailer {
                } else if( $to->address ) {
                        $dest[] = $to->address;
                }
+               if ( count( $dest ) == 0 ) {
+                       return Status::newFatal( 'user-mail-no-addy' );
+               }
 
                if ( $wgEnotifImpersonal ) {
                        $headers['To'] = 'undisclosed-recipients:;';
@@ -231,11 +236,8 @@ class UserMailer {
                        ini_set( 'html_errors', '0' );
                        set_error_handler( 'UserMailer::errorHandler' );
 
-                       if ( !is_array( $to ) ) {
-                               $to = array( $to );
-                       }
-                       foreach ( $to as $recip ) {
-                               $sent = mail( $recip->toString(), self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
+                       foreach ( $dest as $recip ) {
+                               $sent = mail( $recip, self::quotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
                        }
 
                        restore_error_handler();
index 3ef7ddc..91cef94 100644 (file)
@@ -1146,6 +1146,7 @@ Please wait before trying again.',
 'pear-mail-error'        => '$1', # do not translate or duplicate this message to other languages
 'php-mail-error'         => '$1', # do not translate or duplicate this message to other languages
 'php-mail-error-unknown' => "Unknown error in PHP's mail() function",
+'user-mail-no-addy'      => "Tried to send email without an email address",
 
 # Change password dialog
 'resetpass'                 => 'Change password',