Manual:Hooks/AlternateUserMailer

From MediaWiki.org
Jump to navigation Jump to search
AlternateUserMailer
Available from version 1.19.0 (r93415)
Called before mail is sent, so that mail could be logged (or something else) instead of using PEAR or PHP's mail(). Return false to skip the regular method of sending mail. Return a string to return a php-mail-error message containing the error. Returning true will continue with sending email in the regular way.
Define function:
public static function onAlternateUserMailer( $headers, $to, $from, $subject, $body ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"AlternateUserMailer": "MyExtensionHooks::onAlternateUserMailer"
	}
}

For MediaWiki ≤1.25:

$wgHooks['AlternateUserMailer'][] = 'MyExtensionHooks::onAlternateUserMailer';
Called from:File(s): mail/UserMailer.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:AlternateUserMailer extensions.

Details[edit]

  • $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