r99950 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99949‎ | r99950 | r99951 >
Date:12:39, 16 October 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* 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 <address@...>"
* Code simplification
Modified paths:
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/UserMailer.php
@@ -154,39 +154,36 @@
155155 * @return Status object
156156 */
157157 public static function send( $to, $from, $subject, $body, $replyto = null, $contentType = 'text/plain; charset=UTF-8' ) {
158 - global $wgSMTP, $wgEnotifImpersonal;
159 - global $wgEnotifMaxRecips, $wgAdditionalMailParams;
 158+ global $wgSMTP, $wgEnotifMaxRecips, $wgAdditionalMailParams;
160159
161 - $emails = '';
162 - wfDebug( __METHOD__ . ': sending mail to ' . ( is_array( $to ) ? implode( ', ', $to ) : $to ) . "\n" );
 160+ if ( !is_array( $to ) ) {
 161+ $to = array( $to );
 162+ }
163163
164 - $headers['From'] = $from->toString();
165 - $headers['Return-Path'] = $from->toString();
 164+ wfDebug( __METHOD__ . ': sending mail to ' . implode( ', ', $to ) . "\n" );
166165
167166 $dest = array();
168 - if ( is_array( $to ) ) {
169 - foreach ( $to as $u ) {
170 - if ( $u->address ) {
171 - $dest[] = $u->address;
172 - }
 167+ foreach ( $to as $u ) {
 168+ if ( $u->address ) {
 169+ $dest[] = $u->address;
173170 }
174 - } else if( $to->address ) {
175 - $dest[] = $to->address;
176171 }
177172 if ( count( $dest ) == 0 ) {
178173 return Status::newFatal( 'user-mail-no-addy' );
179174 }
180175
181 - if ( $wgEnotifImpersonal ) {
 176+ $headers['From'] = $from->toString();
 177+ $headers['Return-Path'] = $from->address;
 178+ if ( count( $to ) == 1 ) {
 179+ $headers['To'] = $to[0]->toString();
 180+ } else {
182181 $headers['To'] = 'undisclosed-recipients:;';
183182 }
184 - else {
185 - $headers['To'] = implode( ", ", $dest );
186 - }
187183
188184 if ( $replyto ) {
189185 $headers['Reply-To'] = $replyto->toString();
190186 }
 187+
191188 $headers['Subject'] = self::quotedPrintable( $subject );
192189 $headers['Date'] = date( 'r' );
193190 $headers['MIME-Version'] = '1.0';

Follow-up revisions

RevisionCommit summaryAuthorDate
r107920Per request of Reedy, MFT r99942 and r99950ialex18:38, 3 January 2012
r107948Merge r107920, so essentially merging r99942, r99950reedy22:06, 3 January 2012
r111538Note about fixing mail sent to exchange server...hashar14:26, 15 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91662Set envelope sender to the same as the From: address when PEAR mail is used. ...mah18:03, 7 July 2011

Comments

#Comment by Johnduhart (talk | contribs)   16:02, 17 October 2011

(Sorry, wrong commit)

Status & tagging log