*/
class MailAddress {
/**
- * @param $address Mixed: string with an email address, or a User object
+ * @param $address string|User string with an email address, or a User object
* @param $name String: human-readable name if a string address is given
* @param $realName String: human-readable real name if a string address is given
*/
/**
* Send mail using a PEAR mailer
+ *
+ * @param $mailer
+ * @param $dest
+ * @param $headers
+ * @param $body
+ *
+ * @return Status
*/
protected static function sendWithPear( $mailer, $dest, $headers, $body ) {
$mailResult = $mailer->send( $dest, $headers, $body );
require_once( 'Mail.php' );
$msgid = str_replace( " ", "_", microtime() );
- if ( function_exists( 'posix_getpid' ) )
+ if ( function_exists( 'posix_getpid' ) ) {
$msgid .= '.' . posix_getpid();
+ }
if ( is_array( $to ) ) {
$dest = array();
- foreach ( $to as $u )
+ foreach ( $to as $u ) {
$dest[] = $u->address;
- } else
+ }
+ } else {
$dest = $to->address;
+ }
$headers['From'] = $from->toString();
+ $headers['Return-Path'] = $from->toString();
if ( $wgEnotifImpersonal ) {
$headers['To'] = 'undisclosed-recipients:;';
$headers = array(
"MIME-Version: 1.0",
- "Content-type: $contentType",
+ "Content-type: $contentType",
"Content-Transfer-Encoding: 8bit",
"X-Mailer: MediaWiki mailer",
"From: " . $from->toString(),
/**
* Converts a string into a valid RFC 822 "phrase", such as is used for the sender name
+ * @param $phrase string
+ * @return string
*/
public static function rfc822Phrase( $phrase ) {
$phrase = strtr( $phrase, array( "\r" => '', "\n" => '', '"' => '' ) );
return $string;
}
$out = "=?$charset?Q?";
- $out .= preg_replace_callback( "/([$replace])/",
+ $out .= preg_replace_callback( "/([$replace])/",
array( __CLASS__, 'quotedPrintableCallback' ), $string );
$out .= '?=';
return $out;
public function notifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid = false ) {
global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker;
- if ( $title->getNamespace() < 0 )
+ if ( $title->getNamespace() < 0 ) {
return;
+ }
// Build a list of users to notfiy
$watchers = array();
}
- /*
+ /**
* Immediate version of notifyOnPageChange().
*
* Send emails corresponding to the user $editor editing the page $title.
}
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();
$adminAddress = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
$editorAddress = new MailAddress( $editor );
if ( $wgEnotifRevealEditorAddress
- && ( $editor->getEmail() != '' )
- && $editor->getOption( 'enotifrevealaddr' ) ) {
+ && ( $editor->getEmail() != '' )
+ && $editor->getOption( 'enotifrevealaddr' ) ) {
if ( $wgEnotifFromEditor ) {
$from = $editorAddress;
} else {
$replyto = new MailAddress( $wgNoReplyAddress );
}
- if ( $editor->isIP( $name ) ) {
+ if ( $editor->isAnon() ) {
# real anon (user:xxx.xxx.xxx.xxx)
$utext = wfMsgForContent( 'enotif_anon_editor', $name );
$subject = str_replace( '$PAGEEDITOR', $utext, $subject );
$body = str_replace(
array( '$WATCHINGUSERNAME',
- '$PAGEEDITDATE' ),
+ '$PAGEEDITDATE',
+ '$PAGEEDITTIME' ),
array( wfMsgForContent( 'enotif_impersonal_salutation' ),
- $wgContLang->timeanddate( $this->timestamp, true, false, false ) ),
+ $wgContLang->date( $this->timestamp, true, false, false ),
+ $wgContLang->time( $this->timestamp, true, false, false ) ),
$this->body );
return UserMailer::send( $addresses, $this->from, $this->subject, $body, $this->replyto );