From: Bryan Davis Date: Sat, 13 Feb 2016 23:33:08 +0000 (-0700) Subject: Use wiki email for From of CC messages when $wgUserEmailUseReplyTo is set X-Git-Tag: 1.31.0-rc.0~5814^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=582b5a05b805c25843928d58d48f600e2074b7ea;p=lhc%2Fweb%2Fwiklou.git Use wiki email for From of CC messages when $wgUserEmailUseReplyTo is set Avoid bounces caused by SPF protections when sending CC messages to users. This mirrors the logic used when sending the original message. Change-Id: I1c48892e9b5086fd564eedd65cca6a848a2b425c --- diff --git a/includes/specials/SpecialEmailuser.php b/includes/specials/SpecialEmailuser.php index fb1943fb1e..06be7bc327 100644 --- a/includes/specials/SpecialEmailuser.php +++ b/includes/specials/SpecialEmailuser.php @@ -388,13 +388,29 @@ class SpecialEmailUser extends UnlistedSpecialPage { // unless they are emailing themselves, in which case one // copy of the message is sufficient. if ( $data['CCMe'] && $to != $from ) { - $cc_subject = $context->msg( 'emailccsubject' )->rawParams( + $ccTo = $from; + $ccFrom = $from; + $ccSubject = $context->msg( 'emailccsubject' )->rawParams( $target->getName(), $subject )->text(); - - // target and sender are equal, because this is the CC for the sender - Hooks::run( 'EmailUserCC', [ &$from, &$from, &$cc_subject, &$text ] ); - - $ccStatus = UserMailer::send( $from, $from, $cc_subject, $text ); + $ccText = $text; + + Hooks::run( 'EmailUserCC', [ &$ccTo, &$ccFrom, &$ccSubject, &$ccText ] ); + + if ( $config->get( 'UserEmailUseReplyTo' ) ) { + $mailFrom = new MailAddress( + $config->get( 'PasswordSender' ), + wfMessage( 'emailsender' )->inContentLanguage()->text() + ); + $replyTo = $ccFrom; + } else { + $mailFrom = $ccFrom; + $replyTo = null; + } + + $ccStatus = UserMailer::send( + $ccTo, $mailFrom, $ccSubject, $ccText, [ + 'replyTo' => $replyTo, + ] ); $status->merge( $ccStatus ); }