Adamw has submitted this change and it was merged. Change subject: Add the List-Unsubscribe Header ......................................................................
Add the List-Unsubscribe Header Per https://support.google.com/mail/answer/81126?hl=en gmail really likes it if we provide a List-Unsubscribe header. This may help us for long term deliverability. Change-Id: I07a100349244169cbc7d848ba58a5b2876bd34c7 --- M sites/all/modules/thank_you/thank_you.module M sites/all/modules/wmf_common/wmf_communication/Mailer.php 2 files changed, 22 insertions(+), 11 deletions(-) Approvals: Adamw: Looks good to me, approved diff --git a/sites/all/modules/thank_you/thank_you.module b/sites/all/modules/thank_you/thank_you.module index 7d51a62..b9bf5fe 100644 --- a/sites/all/modules/thank_you/thank_you.module +++ b/sites/all/modules/thank_you/thank_you.module @@ -340,7 +340,10 @@ } watchdog("thank_you", "Sending ty email to: " . $email['to_address'], array(), WATCHDOG_INFO); - $email_success = $mailer->send( $email ); + $email_success = $mailer->send( + $email, + array( 'List-Unsubscribe' => build_unsub_link( $contribution_id, $email['to_address'], $language) ) + ); } catch (phpmailerException $e) { //TODO: don't assume phpmailer @@ -613,14 +616,6 @@ and $transaction->is_recurring and time() < mktime( 0, 0, 0, 5, 17, 2012); - $unsub_params = array( - "p" => "thankyou", - "c" => $contribution['id'], - "e" => $contact['email'], - "h" => sha1( $contribution['id'] . $contact['email'] . WMF_UNSUB_SALT ), - "uselang" => $language, - ); - // Format the datestamp $date = strtotime( $contribution['receive_date'] ); if ( $country === 'US' && strftime( "%m-%d" ) === '01-01' ) { @@ -635,7 +630,7 @@ "contribution" => $contribution, "recurring" => $recurring, "misseddonations" => $misseddonations, - "unsubscribe_link" => variable_get( 'thank_you_unsubscribe_url', '' ) . '?' . http_build_query( $unsub_params, '', '&' ), + "unsubscribe_link" => build_unsub_link( $contribution['id'], $contact['email'], $language ), "language" => $language, "country" => $country, "locale" => "{$language}_{$country}", @@ -651,4 +646,16 @@ return $template->render( 'html' ); } +function build_unsub_link( $contributionId, $emailAddr, $language ) { + $unsub_params = array( + "p" => "thankyou", + "c" => $contributionId, + "e" => $emailAddr, + "h" => sha1( $contributionId . $emailAddr . WMF_UNSUB_SALT ), + "uselang" => $language, + ); + + return variable_get( 'thank_you_unsubscribe_url', '' ) . '?' . http_build_query( $unsub_params, '', '&' ); +} + class ThankYouException extends Exception{}; diff --git a/sites/all/modules/wmf_common/wmf_communication/Mailer.php b/sites/all/modules/wmf_common/wmf_communication/Mailer.php index 1408109..a73c8c4 100644 --- a/sites/all/modules/wmf_common/wmf_communication/Mailer.php +++ b/sites/all/modules/wmf_common/wmf_communication/Mailer.php @@ -37,7 +37,7 @@ require_once( $path ); } - function send( $email ) { + function send( $email, $headers = array() ) { watchdog( 'wmf_communication', t( "Sending an email to :to_address, using PHPMailer", array( ':to_address' => $email['to_address'] ) ), WATCHDOG_DEBUG ); $mailer = new \PHPMailer( true ); @@ -50,6 +50,10 @@ $mailer->AddAddress( $email['to_address'], $email['to_name'] ); + foreach ($headers as $header => $value) { + $mailer->AddCustomHeader( "$header: $value" ); + } + $mailer->Subject = $email['subject']; # n.b. - must set AltBody after MsgHTML(), or the text will be overwritten. $mailer->MsgHTML( $email['html'] ); -- To view, visit https://gerrit.wikimedia.org/r/98708 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I07a100349244169cbc7d848ba58a5b2876bd34c7 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/fundraising/crm Gerrit-Branch: master Gerrit-Owner: Mwalker <mwal...@wikimedia.org> Gerrit-Reviewer: Adamw <awi...@wikimedia.org> Gerrit-Reviewer: Katie Horn <kh...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits