From 9d54bc20559b1f2139a737745b52e39ac78aae19 Mon Sep 17 00:00:00 2001 From: Tony Thomas <01tonythomas@gmail.com> Date: Wed, 11 Jun 2014 00:02:42 +0530 Subject: [PATCH] Added VERP functionality hook to core * By default, wiki should keep the envelope sender as $wgPasswordSender * Requires BounceHandler extension. Added hook to core * Alters the return path, to bounce-{key}@domain * The envelope sender is set using the 5th param in mail() Bug: 46640 Needed By: I9463ae33ae327405725ea9693d45ad61b8ecf798 Change-Id: Ic5c1231611a5c4984ddf81fd716e6f3a3e82fd57 --- docs/hooks.txt | 5 +++++ includes/UserMailer.php | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 6e140ba9ce..e4474c53cc 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2969,6 +2969,11 @@ invalidated and GetExtendedMetadata hook called again). $timestamp: The timestamp metadata was generated $file: The file the metadata is for +'UserMailerChangeReturnPath': Called to generate a VERP return address +when UserMailer sends an email, with a bounce handling extension. +$to: Array of MailAddress objects for the recipients +&$returnPath: The return address string + 'WantedPages::getQueryInfo': Called in WantedPagesPage::getQueryInfo(), can be used to alter the SQL query which gets the list of wanted pages. &$wantedPages: WantedPagesPage object diff --git a/includes/UserMailer.php b/includes/UserMailer.php index d73f6b403a..c9db90f85b 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -239,7 +239,17 @@ class UserMailer { # -- hashar 20120218 $headers['From'] = $from->toString(); - $headers['Return-Path'] = $from->address; + $returnPath = $from->address; + $extraParams = $wgAdditionalMailParams; + + // Hook to generate custom VERP address for 'Return-Path' + wfRunHooks( 'UserMailerChangeReturnPath', array( $to, &$returnPath ) ); + # Add the envelope sender address using the -f command line option when PHP mail() is used. + # Will default to the $from->address when the UserMailerChangeReturnPath hook fails and the + # generated VERP address when the hook runs effectively. + $extraParams .= ' -f ' . $returnPath; + + $headers['Return-Path'] = $returnPath; if ( $replyto ) { $headers['Reply-To'] = $replyto->toString(); @@ -371,7 +381,7 @@ class UserMailer { self::quotedPrintable( $subject ), $body, $headers, - $wgAdditionalMailParams + $extraParams ); } } -- 2.20.1