From 582b5a05b805c25843928d58d48f600e2074b7ea Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Sat, 13 Feb 2016 16:33:08 -0700 Subject: [PATCH] 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 --- includes/specials/SpecialEmailuser.php | 28 ++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) 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 ); } -- 2.20.1