r93417 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93416‎ | r93417 | r93418 >
Date:19:38, 28 July 2011
Author:mah
Status:resolved (Comments)
Tags:
Comment:
follow up r93397 — missed msgid
Modified paths:
  • /trunk/phase3/includes/UserMailer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/UserMailer.php
@@ -122,6 +122,18 @@
123123 }
124124
125125 /**
 126+ * Create a value suitable for the MessageId Header
 127+ *
 128+ * @return String
 129+ */
 130+ static function makeMsgId() {
 131+ global $wgServer;
 132+
 133+ $msgid = uniqid( "UserMailer", true ); /* true required for cygwin */
 134+ return "<$msgid@$wgServer>";
 135+ }
 136+
 137+ /**
126138 * This function will perform a direct (authenticated) login to
127139 * a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
128140 * array of parameters. It requires PEAR:Mail to do that.
@@ -175,8 +187,8 @@
176188 $headers['Content-type'] = ( is_null( $contentType ) ?
177189 'text/plain; charset=UTF-8' : $contentType );
178190 $headers['Content-transfer-encoding'] = '8bit';
179 - // @todo FIXME
180 - $headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>';
 191+
 192+ $headers['Message-ID'] = self::makeMsgId();
181193 $headers['X-Mailer'] = 'MediaWiki mailer';
182194 $headers['From'] = $from->toString();
183195
@@ -198,11 +210,6 @@
199211 }
200212 require_once( 'Mail.php' );
201213
202 - $msgid = str_replace( " ", "_", microtime() );
203 - if ( function_exists( 'posix_getpid' ) ) {
204 - $msgid .= '.' . posix_getpid();
205 - }
206 -
207214 wfSuppressWarnings();
208215
209216 // Create the mail object using the Mail::factory method

Follow-up revisions

RevisionCommit summaryAuthorDate
r95547Followup r93417; Don't use $wgServer in a way that makes invalid Message-IDs....dantman00:01, 26 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93397Reduce mail header differences by moving all the header creation code...mah16:56, 28 July 2011

Comments

#Comment by Dantman (talk | contribs)   21:05, 25 August 2011

Message-IDs like "<UserMailer4e56b856ae9867.11102601@http://yourwiki.com>" are not valid, the @ portion is supposed to be in a domain format, not a full url.

I think we should probably introduce a new config, something like $wgEnotifMessageIDDomain, and handle decision on what domain to use with something like:

if ( $wgEnotifMessageIDDomain ) {
  $domain = $wgEnotifMessageIDDomain;
} elseif ( isset($wgSMTP['IDHost']) && $wgSMTP['IDHost'] ) {
  $domain = $wgSMTP['IDHost'];
} else {
  $url = wfParseUrl($wgServer);
  $domain = $url['host'];
}
// [...]
return "<$msgid@$domain>";

Also, I don't really know about the 'UserMailer' prepend.

#Comment by Dantman (talk | contribs)   21:20, 25 August 2011

Rather than a 'UserMailer' prepend, perhaps wfWikiID would make more sense.

Status & tagging log