From: Antoine Musso Date: Wed, 18 May 2011 20:17:26 +0000 (+0000) Subject: makes UserMailer::send() a bit simpler X-Git-Tag: 1.31.0-rc.0~30086 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=ad2d7ad56e102027e21a425ec1c84cdea4e5c04c;p=lhc%2Fweb%2Fwiklou.git makes UserMailer::send() a bit simpler * $contentType now default to 'text/plain; charset=UTF-8'; * uses array instead of string concatenations --- diff --git a/includes/UserMailer.php b/includes/UserMailer.php index f4f6b3bed0..0798c3226d 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -106,10 +106,10 @@ class UserMailer { * @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 @@ class UserMailer { 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 @@ class UserMailer { } 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 = '';