API:Emailuser/ja
![]() | このページは MediaWiki 操作 API の説明文書の一部です。 |
Emailuser | ||
---|---|---|
Email a user. このモジュールは generator としては使用できません。 |
||
接頭辞 | なし | |
必要な権限 | sendemail | |
POST のみ? | はい | |
自動生成ヘルプ | 現行バージョン | |
追加されたバージョン |
|
トークン[edit]
メールを送信するにはトークンが必要です。このトークンは編集のためのトークンと同一のもので、送信先に関わらず同じですが、ログインの度に変わります。メールトークンは action=tokens で type=email を指定する(MW 1.20+), または以下の方法で取得できます:
Obtaining an email token
結果 |
---|
{
"batchcomplete": "",
"query": {
"tokens": {
"csrftoken": "7773cbfff263682c97ffc74b8672cbf25a5e0045+\\"
}
}
}
|
利用者へのメールの送信[edit]
メールアドレスを認証した利用者に action=emailuser でメールを送信することができます。Sending email is subject to rate limits.
パラメーター[edit]
target
: メールの宛先の利用者subject
: メッセージの件名text
: メッセージtoken
: 以前のリクエストで取得したトークン。必ず+
を%2B
にエンコードしてください。ccme
: 設定すると、メールのコピーをあなたにお送りします
例[edit]
注記: 簡潔性のためにこの例ではすべてのパラメーターをGETリクエストで渡していますが, action=emailuser はPOSTリクエストを必要とします; GETリクエストだとエラーが発生します。
Sending an email to User:Catrope
結果 |
---|
<?xml version="1.0" encoding="utf-8"?>
<api>
<emailuser result="Success" />
</api>
|
起こりうるエラー[edit]
In addition to the usual stuff:
Code | Info |
---|---|
cantsend | You are not logged in, you do not have a confirmed email address, or you are not allowed to send email to other users, so you cannot send email. |
blockedfrommail | You have been blocked from sending email. |
usermaildisabled | User email has been disabled |
notarget | You have not specified a valid target for this action. |
noemail | この利用者は有効なメールアドレスを登録していません。 この利用者は他の利用者からメールを受け取らない設定にしています。 |
Checking emailable status[edit]
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;
![]() | 以下の説明文書は、このサイト (MediaWiki.org) で稼働しているリリース前のバージョンのMediaWikiによって自動的に生成された、Special:ApiHelp/emailuser の出力です。 |
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.
- 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]