*/
static function send( $to, $from, $subject, $body, $replyto=null, $contentType=null ) {
global $wgSMTP, $wgOutputEncoding, $wgEnotifImpersonal;
- global $wgEnotifMaxRecips;
+ global $wgEnotifMaxRecips, $wgAdditionalMailParams;
if ( is_array( $to ) ) {
// This wouldn't be necessary if implode() worked on arrays of
}
if (is_array( $wgSMTP )) {
+ $found = false;
+ $pathArray = explode( PATH_SEPARATOR, get_include_path() );
+ foreach ( $pathArray as $path ) {
+ if ( file_exists( $path . DIRECTORY_SEPARATOR . 'Mail.php' ) ) {
+ $found = true;
+ break;
+ }
+ }
+ if ( !$found ) {
+ throw new MWException( 'PEAR mail package is not installed' );
+ }
require_once( 'Mail.php' );
$msgid = str_replace(" ", "_", microtime());
$headers['Message-ID'] = "<$msgid@" . $wgSMTP['IDHost'] . '>'; // FIXME
$headers['X-Mailer'] = 'MediaWiki mailer';
+ wfSuppressWarnings();
+
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', $wgSMTP);
if( PEAR::isError( $mail_object ) ) {
wfDebug( "PEAR::Mail factory failed: " . $mail_object->getMessage() . "\n" );
+ wfRestoreWarnings();
return new WikiError( $mail_object->getMessage() );
}
$chunks = array_chunk( (array)$dest, $wgEnotifMaxRecips );
foreach ($chunks as $chunk) {
$e = self::sendWithPear($mail_object, $chunk, $headers, $body);
- if( WikiError::isError( $e ) )
+ if( WikiError::isError( $e ) ) {
+ wfRestoreWarnings();
return $e;
+ }
}
+ wfRestoreWarnings();
} 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)
if (is_array($to)) {
foreach ($to as $recip) {
- $sent = mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers );
+ $sent = mail( $recip->toString(), wfQuotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
}
} else {
- $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers );
+ $sent = mail( $to->toString(), wfQuotedPrintable( $subject ), $body, $headers, $wgAdditionalMailParams );
}
restore_error_handler();
'wl_notificationtimestamp IS NULL',
), __METHOD__
);
- while ($row = $dbw->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$watchers[] = intval( $row->wl_user );
}
if ($watchers) {
* @private
*/
function composeCommonMailtext() {
- global $wgPasswordSender, $wgNoReplyAddress;
+ global $wgPasswordSender, $wgPasswordSenderName, $wgNoReplyAddress;
global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
global $wgEnotifImpersonal, $wgEnotifUseRealName;
$keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' );
}
- if ($wgEnotifImpersonal && $this->oldid)
+ if ($wgEnotifImpersonal && $this->oldid) {
/*
* For impersonal mail, show a diff link to the last
* revision.
*/
$keys['$NEWPAGE'] = wfMsgForContent('enotif_lastdiff',
$this->title->getFullURL("oldid={$this->oldid}&diff=next"));
+ }
$body = strtr( $body, $keys );
$pagetitle = $this->title->getPrefixedText();
# global configuration level.
$editor = $this->editor;
$name = $wgEnotifUseRealName ? $editor->getRealName() : $editor->getName();
- $adminAddress = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
+ $adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
$editorAddress = new MailAddress( $editor );
if( $wgEnotifRevealEditorAddress
&& ( $editor->getEmail() != '' )
} # end of class EmailNotification
-/**
+/**@{
* Backwards compatibility functions
+ *
+ * @deprecated Use UserMailer methods; will be removed in 1.19
*/
function wfRFC822Phrase( $s ) {
+ wfDeprecated( __FUNCTION__ );
return UserMailer::rfc822Phrase( $s );
}
function userMailer( $to, $from, $subject, $body, $replyto=null ) {
+ wfDeprecated( __FUNCTION__ );
return UserMailer::send( $to, $from, $subject, $body, $replyto );
}
+/**@}*/
\ No newline at end of file