http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88389
Revision: 88389
Author: hashar
Date: 2011-05-18 20:17:26 +0000 (Wed, 18 May 2011)
Log Message:
-----------
makes UserMailer::send() a bit simpler
* $contentType now default to 'text/plain; charset=UTF-8';
* uses array instead of string concatenations
Modified Paths:
--------------
trunk/phase3/includes/UserMailer.php
Modified: trunk/phase3/includes/UserMailer.php
===================================================================
--- trunk/phase3/includes/UserMailer.php 2011-05-18 20:12:29 UTC (rev
88388)
+++ trunk/phase3/includes/UserMailer.php 2011-05-18 20:17:26 UTC (rev
88389)
@@ -106,10 +106,10 @@
* @param $subject String: email's subject.
* @param $body String: email's text.
* @param $replyto MailAddress: optional reply-to email (default: null).
- * @param $contentType String: optional custom Content-Type
+ * @param $contentType String: optional custom Content-Type (default:
text/plain; charset=UTF-8)
* @return Status object
*/
- public static function send( $to, $from, $subject, $body, $replyto =
null, $contentType = null ) {
+ public static function send( $to, $from, $subject, $body, $replyto =
null, $contentType = 'text/plain; charset=UTF-8') {
global $wgSMTP, $wgEnotifImpersonal;
global $wgEnotifMaxRecips, $wgAdditionalMailParams;
@@ -192,9 +192,6 @@
wfRestoreWarnings();
return Status::newGood();
} else {
- # In the following $headers = expression we removed
"Reply-To: {$from}\r\n" , because it is treated differently
- # (fifth parameter of the PHP mail function, see some
lines below)
-
# Line endings need to be different on Unix and Windows
due to
# the bug described at
http://trac.wordpress.org/ticket/2603
if ( wfIsWindows() ) {
@@ -203,18 +200,20 @@
} else {
$endl = "\n";
}
- $ctype = ( is_null( $contentType ) ?
- 'text/plain; charset=UTF-8' :
$contentType );
- $headers =
- "MIME-Version: 1.0$endl" .
- "Content-type: $ctype$endl" .
- "Content-Transfer-Encoding: 8bit$endl" .
- "X-Mailer: MediaWiki mailer$endl" .
- 'From: ' . $from->toString();
+
+ $headers = array(
+ "MIME-Version: 1.0",
+ "Content-type: $contentType",
+ "Content-Transfer-Encoding: 8bit",
+ "X-Mailer: MediaWiki mailer",
+ "From: " . $from->toString(),
+ );
if ( $replyto ) {
- $headers .= "{$endl}Reply-To: " .
$replyto->toString();
+ $headers[] = "Reply-To: " .
$replyto->toString();
}
+ $headers = implode( $endl, $headers );
+
wfDebug( "Sending mail via internal mail() function\n"
);
self::$mErrorString = '';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs