MediaWiki r30014 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r30013‎ | r30014 (on ViewVC)‎ | r30015 >
Date:07:05, 21 January 2008
Author:brion
Status:old
Tags:
Comment:
* (bug 12655) Added $wgUserEmailUseReplyTo config option to put sender
address in Reply-To instead of From for user-to-user emails.
This protects against SPF problems and privacy-leaking bounce messages
when using mailers that set the envelope sender to the From header value.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/SpecialEmailuser.php
===================================================================
--- trunk/phase3/includes/SpecialEmailuser.php	(revision 30013)
+++ trunk/phase3/includes/SpecialEmailuser.php	(revision 30014)
@@ -143,15 +143,43 @@
 	}
 
 	function doSubmit() {
-		global $wgOut, $wgUser;
+		global $wgOut, $wgUser, $wgUserEmailUseReplyTo;
 
 		$to = new MailAddress( $this->target );
 		$from = new MailAddress( $wgUser );
 		$subject = $this->subject;
 
 		if( wfRunHooks( 'EmailUser', array( &$to, &$from, &$subject, &$this->text ) ) ) {
+			
+			if( $wgUserEmailUseReplyTo ) {
+				// Put the generic wiki autogenerated address in the From:
+				// header and reserve the user for Reply-To.
+				//
+				// This is a bit ugly, but will serve to differentiate
+				// wiki-borne mails from direct mails and protects against
+				// SPF and bounce problems with some mailers (see below).
+				global $wgEmergencyContact;
+				$mailFrom = new MailAddress( $wgEmergencyContact );
+				$replyTo = $from;
+			} else {
+				// Put the sending user's e-mail address in the From: header.
+				//
+				// This is clean-looking and convenient, but has issues.
+				// One is that it doesn't as clearly differentiate the wiki mail
+				// from "directly" sent mails.
+				//
+				// Another is that some mailers (like sSMTP) will use the From
+				// address as the envelope sender as well. For open sites this
+				// can cause mails to be flunked for SPF violations (since the
+				// wiki server isn't an authorized sender for various users'
+				// domains) as well as creating a privacy issue as bounces
+				// containing the recipient's e-mail address may get sent to
+				// the sending user.
+				$mailFrom = $from;
+				$replyTo = null;
+			}
 
-			$mailResult = userMailer( $to, $from, $subject, $this->text );
+			$mailResult = UserMailer::send( $to, $mailFrom, $subject, $this->text, $replyTo );
 
 			if( WikiError::isError( $mailResult ) ) {
 				$wgOut->addHTML( wfMsg( "usermailererror" ) . $mailResult);
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 30013)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 30014)
@@ -510,6 +510,16 @@
 $wgEnableUserEmail = true;
 
 /**
+ * Set to true to put the sending user's email in a Reply-To header
+ * instead of From. ($wgEmergencyContact will be used as From.)
+ *
+ * Some mailers (eg sSMTP) set the SMTP envelope sender to the From value,
+ * which can cause problems with SPF validation and leak recipient addressses
+ * when bounces are sent to the sender.
+ */
+$wgUserEmailUseReplyTo = false;
+
+/**
  * Minimum time, in hours, which must elapse between password reminder
  * emails for a given account. This is to prevent abuse by mail flooding.
  */
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 30013)
+++ trunk/phase3/RELEASE-NOTES	(revision 30014)
@@ -136,6 +136,10 @@
 * (bug 10049) Prefix index search and namespaces in Special:Withoutinterwiki
 * (bug 12668) Support for custom iPhone bookmark icon via $wgAppleTouchIcon
 * Add option to include templates in Special:Export.
+* (bug 12655) Added $wgUserEmailUseReplyTo config option to put sender
+  address in Reply-To instead of From for user-to-user emails.
+  This protects against SPF problems and privacy-leaking bounce messages
+  when using mailers that set the envelope sender to the From header value.
 
 
 === Bug fixes in 1.12 ===

Follow-up revisions

Rev.Commit summaryAuthorDate
r30027* re-add bug 12655 that was added in r30014 and disappeared in r30020...siebrand18:13, 21 January 2008

Status & tagging log

  • 15:24, 12 September 2011 Meno25 (Talk | contribs) changed the status of r30014 [removed: ok added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox