API:Edit - Send e-mail

From MediaWiki.org

Jump to: navigation, search
This page is part of the MediaWiki API documentation.
MediaWiki API


MediaWiki version: 1.14

Contents

[edit] Token

To send an e-mail, an e-mail token is required. This token is equal to the edit token and the same for all recipients, but changes at every login. An e-mail token can be obtained as follows:

Obtaining an e-mail token

api.php ? action=query & prop=info & intoken=email & titles=User:Catrope

<?xml version="1.0" encoding="utf-8"?>
<api>
  <query>
    <pages>
      <page
        pageid="1"
        ns="2"
        title="User:Catrope"
        touched="2007-09-03T20:32:21Z"
        lastrevid="20"
        counter="20"
        length="470"
        emailtoken="58b54e0bab4a1d3fd3f7653af38e75cb+\" 
      />
    </pages>
  </query>
</api>

[edit] Sending e-mail to users

You can send e-mail to users who have a confirmed e-mail address with action=emailuser.

[edit] Parameters

  • target: User to send e-mail to
  • subject: The subject of the message
  • text: The message
  • token: The token obtained in the previous request. Take care to encode the + as %2B
  • ccme: If set, a copy of the e-mail will be sent to you

[edit] Examples

Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=emailuser requires POST requests; GET requests will cause an error.


Sending an e-mail to User:Catrope

api.php ? action=emailuser & target=Catrope & subject=Hi & text=Just%20wanted%20to%20say%20hi

<?xml version="1.0" encoding="utf-8"?>
<api>
  <emailuser result="Success" />
</api>

[edit] Possible errors

In addition to the usual stuff:

  • code: cantsend
    • info: You're not logged in or you don't have a confirmed e-mail address, so you can't send e-mail
  • code: blockedfrommail
    • info: You have been blocked from sending e-mail
  • code: usermaildisabled
    • info: User email has been disabled
  • code: notarget
    • info: You have not specified a valid target for this action
  • code: noemail
    • info: The user has not specified a valid e-mail address, or has chosen not to receive e-mail from other users
Personal tools