52 if ( $target ==
'' ) {
72 if ( !$target instanceof
User || !$target->
getId() ) {
73 wfDebug(
"Target is invalid user." );
78 if ( !$target->isEmailConfirmed() ) {
79 wfDebug(
"User has no valid email." );
84 if ( !$target->canReceiveEmail() ) {
85 wfDebug(
"User does not allow user emails." );
91 ->getUserOptionsLookup();
92 if ( !$userOptionsLookup->getOption(
94 'email-allow-new-users'
97 wfDebug(
"User does not allow user emails from new users." );
102 $muteList = $userOptionsLookup->getOption(
110 ->getCentralIdLookup()
111 ->centralIdFromLocalUser( $sender );
112 if ( $senderId !== 0 && in_array( $senderId, $muteList ) ) {
113 wfDebug(
"User does not allow user emails from this user." );
115 return 'nowikiemail';
132 if ( $config ===
null ) {
133 wfDebug( __METHOD__ .
' called without a Config instance passed to it' );
138 return 'usermaildisabled';
143 if ( !$user->isEmailConfirmed() ) {
144 return 'mailnologin';
148 ->getPermissionManager()
149 ->userHasRight( $user,
'sendemail' )
154 if ( $user->isBlockedFromEmailuser() ) {
155 wfDebug(
"User is blocked from sending e-mail." );
157 return "blockedemailuser";
162 if ( $user->pingLimiter(
'sendemail', 0 ) ) {
163 wfDebug(
"Ping limiter triggered." );
165 return 'actionthrottledtext';
170 Hooks::runner()->onUserCanSendEmail( $user, $hookErr );
171 Hooks::runner()->onEmailUserPermissionsErrors( $user, $editToken, $hookErr );
173 return $hookErr ?:
null;
191 if ( !$target instanceof
User ) {
193 return Status::newFatal( $target .
'text' );
196 $toAddress = MailAddress::newFromUser( $target );
197 $fromAddress = MailAddress::newFromUser( $sender );
198 $subject = $data[
'Subject'];
199 $text = $data[
'Text'];
202 $text = rtrim( $text ) .
"\n\n-- \n";
203 $text .= $context->
msg(
207 )->inContentLanguage()->text();
211 $text .=
"\n" . $context->
msg(
212 'specialmute-email-footer',
213 $specialMutePage->getCanonicalURL(),
215 )->inContentLanguage()->text();
219 if ( $sender->pingLimiter(
'sendemail' ) ) {
225 $hookRunner = Hooks::runner();
229 if ( !$hookRunner->onEmailUser( $toAddress, $fromAddress, $subject, $text, $error ) ) {
230 if ( $error instanceof
Status ) {
232 } elseif ( $error ===
false || $error ===
'' || $error === [] ) {
235 } elseif ( $error ===
true ) {
237 return Status::newGood();
238 } elseif ( is_array( $error ) ) {
239 $status = Status::newGood();
240 foreach ( $error as $e ) {
241 $status->fatal( $e );
245 return Status::newFatal( $error );
249 $type = is_object( $error ) ? get_class( $error ) : gettype( $error );
251 'EmailUser hook set $error to unsupported type ' .
$type
267 $context->
msg(
'emailsender' )->inContentLanguage()->text()
269 $replyTo = $fromAddress;
286 $mailFrom = $fromAddress;
290 $status = Status::wrap( $emailer->send(
296 [
'replyTo' => $replyTo ]
299 if ( !$status->isGood() ) {
306 if ( $data[
'CCMe'] && $toAddress != $fromAddress ) {
307 $ccTo = $fromAddress;
308 $ccFrom = $fromAddress;
309 $ccSubject = $context->
msg(
'emailccsubject' )->plaintextParams(
315 $hookRunner->onEmailUserCC( $ccTo, $ccFrom, $ccSubject, $ccText );
320 $context->
msg(
'emailsender' )->inContentLanguage()->text()
328 $ccStatus = $emailer->send(
334 [
'replyTo' => $replyTo ]
336 $status->merge( $ccStatus );
339 $hookRunner->onEmailUserComplete( $toAddress, $fromAddress, $subject, $text );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Stores a single person's name and email address.
A class containing constants representing the names of configuration variables.
const EnableUserEmail
Name constant for the EnableUserEmail setting, for use with Config::get()
const EnableSpecialMute
Name constant for the EnableSpecialMute setting, for use with Config::get()
const EnableEmail
Name constant for the EnableEmail setting, for use with Config::get()
const PasswordSender
Name constant for the PasswordSender setting, for use with Config::get()
const UserEmailUseReplyTo
Name constant for the UserEmailUseReplyTo setting, for use with Config::get()
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Show an error when the user hits a rate limit.
static newFromName( $name, $validate='valid')
isNewbie()
Determine whether the user is a newbie.
getId( $wikiId=self::LOCAL)
Get the user's ID.
Interface for configuration instances.
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
msg( $key,... $params)
This is the method for getting translated interface messages.