From: Mark A. Hershberger Date: Thu, 28 Jul 2011 19:19:42 +0000 (+0000) Subject: Add hook that could be the solution for Bug #28026 (“Enable e-mail X-Git-Tag: 1.31.0-rc.0~28555 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=e5a99a4262778dc3add1346e4d2bd6971e330807;p=lhc%2Fweb%2Fwiklou.git Add hook that could be the solution for Bug #28026 (“Enable e-mail notifications for watchlist (EnotifWatchlist) on all small wikis”) to make logging sent emails easier. --- diff --git a/docs/hooks.txt b/docs/hooks.txt index bf4a46e430..abe40a7b73 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -295,6 +295,15 @@ before showing the edit form ( EditPage::edit() ). This is triggered on &action=edit. $EditPage: the EditPage object +'AlternateUserMailer': Called before mail is sent so that mail could +be logged (or something else) instead of using PEAR or SMTP +$UserMailer: the EditPage object +$headers: Associative array of headers for the email +$to: MailAddress object or array +$from: From address +$subject: Subject of the email +$body: Body of the message + 'APIAfterExecute': after calling the execute() method of an API module. Use this to extend core API modules. &$module: Module object diff --git a/includes/UserMailer.php b/includes/UserMailer.php index 1bb7c08875..1009337132 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -180,6 +180,13 @@ class UserMailer { $headers['X-Mailer'] = 'MediaWiki mailer'; $headers['From'] = $from->toString(); + $ret = wfRunHooks( 'AlternateUserMailer', array( $this, $headers, $to, $from, $subject, $body, $replyto, $contentType ) ) ) { + if ( $ret === false ) { + return Status::newGood(); + } else if ( $ret != true ) { + return Status::newFatal( 'php-mail-error', $ret ); + } + if ( is_array( $wgSMTP ) ) { if ( function_exists( 'stream_resolve_include_path' ) ) { $found = stream_resolve_include_path( 'Mail.php' );