From d199c452f5a82c79e1c377da896383d92d8c16c5 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sun, 16 Oct 2011 12:39:05 +0000 Subject: [PATCH] * Send "undisclosed-recipients" in "To" header when sending the mail to more than one user instead of checking $wgEnotifImpersonal. This was causing Special:EmailUser to send mails with that header when $wgEnotifImpersonal is true * Fix for r91662: Return-Path must an e-mail address and only a e-mail address, it cannot be "Name " * Code simplification --- includes/UserMailer.php | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/includes/UserMailer.php b/includes/UserMailer.php index 49577f7cfb..fdb209fb19 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -154,39 +154,36 @@ class UserMailer { * @return Status object */ public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8' ) { - global $wgSMTP, $wgEnotifImpersonal; - global $wgEnotifMaxRecips, $wgAdditionalMailParams; + global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams; - $emails = ''; - wfDebug( __METHOD__ . ': sending mail to ' . ( is_array( $to ) ? implode( ', ', $to ) : $to ) . "\n" ); + if ( !is_array( $to ) ) { + $to = array( $to ); + } - $headers['From'] = $from->toString(); - $headers['Return-Path'] = $from->toString(); + wfDebug( __METHOD__ . ': sending mail to ' . implode( ', ', $to ) . "\n" ); $dest = array(); - if ( is_array( $to ) ) { - foreach ( $to as $u ) { - if ( $u->address ) { - $dest[] = $u->address; - } + foreach ( $to as $u ) { + if ( $u->address ) { + $dest[] = $u->address; } - } else if( $to->address ) { - $dest[] = $to->address; } if ( count( $dest ) == 0 ) { return Status::newFatal( 'user-mail-no-addy' ); } - if ( $wgEnotifImpersonal ) { + $headers['From'] = $from->toString(); + $headers['Return-Path'] = $from->address; + if ( count( $to ) == 1 ) { + $headers['To'] = $to[0]->toString(); + } else { $headers['To'] = 'undisclosed-recipients:;'; } - else { - $headers['To'] = implode( ", ", $dest ); - } if ( $replyto ) { $headers['Reply-To'] = $replyto->toString(); } + $headers['Subject'] = self::quotedPrintable( $subject ); $headers['Date'] = date( 'r' ); $headers['MIME-Version'] = '1.0'; -- 2.20.1