From e1f03a8c0e5d3244fb99f44cb804ed2fb838c5ff Mon Sep 17 00:00:00 2001 From: lwelling Date: Wed, 17 Apr 2013 12:26:05 -0400 Subject: [PATCH] Split out notification emails to a separate from address so they can be configured as specified for launch. Part of https://bugzilla.wikimedia.org/show_bug.cgi?id=46670 Change-Id: I06a73aae95bc4b6776a0554b624eccfc4602bc65 --- Echo.php | 8 ++++++++ Notifier.php | 9 +++++---- includes/EmailBatch.php | 9 +++++---- includes/EmailBundler.php | 9 +++++---- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Echo.php b/Echo.php index 9f012e022..2be350d16 100644 --- a/Echo.php +++ b/Echo.php @@ -218,6 +218,14 @@ $wgEchoUseJobQueue = false; // The organization address, the value should be defined in LocalSettings.php $wgEchoEmailFooterAddress = ''; +// The email address for both "from" and "reply to" on email notifications. +// Should be defined in LocalSettings.php +$wgNotificationSender = $wgPasswordSender; +// Name for "from" on email notifications. Should be defined in LocalSettings.php +$wgNotificationSenderName = $wgPasswordSenderName; +// Name for "reply to" on email notifications. Should be defined in LocalSettings.php +$wgNotificationReplyName = 'No Reply'; + // Use the main db if this is set to false, to use a specific external db, just // use any key defined in $wgExternalServers $wgEchoCluster = false; diff --git a/Notifier.php b/Notifier.php index 5177d0a20..c2fd98b91 100644 --- a/Notifier.php +++ b/Notifier.php @@ -65,7 +65,7 @@ class EchoNotifier { // See if the user wants to receive emails for this category if ( $user->getOption( 'echo-subscriptions-email-' . $event->getCategory() ) ) { - global $wgEchoEnableEmailBatch, $wgEchoNotifications, $wgPasswordSender, $wgPasswordSenderName, $wgEchoBundleEmailInterval; + global $wgEchoEnableEmailBatch, $wgEchoNotifications, $wgNotificationSender, $wgNotificationSenderName, $wgNotificationReplyName, $wgEchoBundleEmailInterval; $priority = EchoNotificationController::getNotificationPriority( $event->getType() ); @@ -108,8 +108,9 @@ class EchoNotifier { // send single notification if the email wasn't added to queue for bundling if ( !$addedToQueue ) { // instant email notification - $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName ); - $address = new MailAddress( $user ); + $toAddress = new MailAddress( $user ); + $fromAddress = new MailAddress( $wgNotificationSender, $wgNotificationSenderName ); + $replyAddress = new MailAddress( $wgNotificationSender, $wgNotificationReplyName ); // Since we are sending a single email, should set the bundle hash to null // if it is set with a value from somewhere else $event->setBundleHash( null ); @@ -117,7 +118,7 @@ class EchoNotifier { $subject = $email['subject']; $body = $email['body']; - UserMailer::send( $address, $adminAddress, $subject, $body ); + UserMailer::send( $toAddress, $fromAddress, $subject, $body, $replyAddress ); } } diff --git a/includes/EmailBatch.php b/includes/EmailBatch.php index 8caf9b5ce..750b481bd 100644 --- a/includes/EmailBatch.php +++ b/includes/EmailBatch.php @@ -217,7 +217,7 @@ abstract class MWEchoEmailBatch { * Send the batch email */ public function sendEmail() { - global $wgPasswordSender, $wgPasswordSenderName, $wgEchoEmailFooterAddress; + global $wgNotificationSender, $wgNotificationSenderName, $wgNotificationReplyName, $wgEchoEmailFooterAddress; // global email footer $footer = wfMessage( 'echo-email-footer-default' ) @@ -247,11 +247,12 @@ abstract class MWEchoEmailBatch { $footer )->text(); - $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName ); - $address = new MailAddress( $this->mUser ); + $toAddress = new MailAddress( $this->mUser ); + $fromAddress = new MailAddress( $wgNotificationSender, $wgNotificationSenderName ); + $replyAddress = new MailAddress( $wgNotificationSender, $wgNotificationReplyName ); // @Todo Push the email to job queue or just send it out directly? - UserMailer::send( $address, $adminAddress, $subject, $body ); + UserMailer::send( $toAddress, $fromAddress, $subject, $body, $replyAddress ); } /** diff --git a/includes/EmailBundler.php b/includes/EmailBundler.php index 7b96cd673..0008de6e5 100644 --- a/includes/EmailBundler.php +++ b/includes/EmailBundler.php @@ -244,13 +244,14 @@ abstract class MWEchoEmailBundler { return; } - global $wgPasswordSender, $wgPasswordSenderName; + global $wgNotificationSender, $wgNotificationSenderName, $wgNotificationReplyName; - $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName ); - $address = new MailAddress( $this->mUser ); + $toAddress = new MailAddress( $this->mUser ); + $fromAddress = new MailAddress( $wgNotificationSender, $wgNotificationSenderName ); + $replyAddress = new MailAddress( $wgNotificationSender, $wgNotificationReplyName ); // Schedule a email job or just send the email directly? - UserMailer::send( $address, $adminAddress, $content['subject'], $content['body'] ); + UserMailer::send( $toAddress, $fromAddress, $content['subject'], $content['body'], $replyAddress ); } /**