API:Emailuser/fr
Cette page fait partie de la documentation de l'API MediaWiki Action. |
Emailuser | ||
---|---|---|
Email a user. Ce module ne peut pas être utilisé comme générateur. | ||
Préfixe | aucun | |
Droits exigés | sendemail | |
POST seulement ? | Oui | |
Aide générée | Version actuelle | |
Ajouté en version |
|
Jeton
To send an email, an email token is required. This token is equal to the edit token and the same for all recipients, but changes at every login. Email tokens can be obtained via action=query&meta=tokens , or by using the following method:
Résultat |
---|
{
"batchcomplete": "",
"query": {
"tokens": {
"csrftoken": "7773cbfff263682c97ffc74b8672cbf25a5e0045+\\"
}
}
}
|
Envoyer des courriels aux utilisateurs
You can send email to users who have a confirmed email address with action=emailuser. Sending email is subject to rate limits.
Paramètres
target
: User to send email tosubject
: The subject of the messagetext
: The messagetoken
: The token obtained in the previous request. Take care to encode the+
as%2B
ccme
: If set, a copy of the email will be sent to you
Exemples
Résultat |
---|
<?xml version="1.0" encoding="utf-8"?>
<api>
<emailuser result="Success" />
</api>
|
Exemple de code
Erreurs possibles
In addition to the usual stuff :
Code | Info |
---|---|
cantsend | Vous n’êtes pas connecté, vous n’avez pas d’adresse de courriel confirmée, ou vous n’êtes pas autorisé à envoyer des courriels aux autres utilisateurs, donc vous ne pouvez envoyer de courriel. |
blockedfrommail | Vous avez été bloqué pour l’envoi de courriel. |
usermaildisabled | User email has been disabled |
notarget | ⧼apierror-notarget⧽ |
noemail | Cet utilisateur n’a pas spécifié une adresse de courriel valide. |
nowikiemail | Cet utilisateur a choisi de ne pas recevoir de courriel de la part d’autres utilisateurs. |
Checking emailable status
Before trying to send an email, it is recommended to check if the user is emailable first. To do this, you can execute a list query on the user (or several users at once). Here is an example using Ajax:
new mw.Api().get( {
action: 'query',
list: 'users',
ususers: mw.config.get( 'wgTitle' ),
usprop: 'emailable',
rawcontinue: ''
} ).done( function( getEmailable ) {
alert( ( getEmailable.query.users[ 0 ][ 'emailable' ] !== undefined ) ? 'emailable' : 'not emailable' );
} );
If you are testing from a client-side script, it is also possible to simply check for the existence of the t-emailuser list item:
emailable = $( '#t-emailuser' ).length ? true : false;
La documentation qui suit est le résultat de Special: |
action=emailuser
- This module requires read rights.
- This module requires write rights.
- This module only accepts POST requests.
- Source: MediaWiki
- License: GPL-2.0-or-later
Email a user.
- target
User to send the email to.
- This parameter is required.
- subject
Subject header.
- This parameter is required.
- text
Email body.
- This parameter is required.
- ccme
Send a copy of this mail to me.
- Type: boolean (details)
- token
A "csrf" token retrieved from action=query&meta=tokens
- This parameter is required.
- Send an email to the user WikiSysop with the text Content.
- api.php?action=emailuser&target=WikiSysop&text=Content&token=123ABC [open in sandbox]