Plesk Automation API - Get Mail Info

Discussion in 'Plesk Automation Suggestions and Feedback' started by JoshEdney-CH, Dec 3, 2015.

  1. JoshEdney-CH

    JoshEdney-CH Bit Poster

    Messages:
    5
    Hi,

    We are playing around with the plesk api and are trying to get information about email accounts back.

    Below is the request packet that is sent to the server.

    Code:
    <packet version="1.6.5.0">
                <mail>   
                <get_info>
                  <filter>
                     <site-id>12</site-id>
                  </filter>
                  <mailbox/>
                </get_info>
                </mail>
                </packet>
    
    This is what we get back from the server.

    Code:
    [2] => Array
      (
      [status] => ok
      [mailname] => Array
      (
      [id] => 588
      [name] => superman
      [mailbox] => Array
      (
      [enabled] => true
      [quota] => -1
       )
      [password] => Array
      (
      [value] => Array
      (
      )
      [type] => sym
       )
      [antivir] => in
      )
      )
    The part that we are unsure about is the quota isn't returning the correct value. The mailbox currently has 1.2GB stored in it so not sure why it returns a -1 ?

    any help or advice that can be given would be much appreciated.

    Cheers

    Josh - CH
     
  2. abdi

    abdi Product Expert

    Messages:
    2,755
    -1 is Unlimited and that is the quota assigned to the email address ...(NOT the used space)
     
  3. JoshEdney-CH

    JoshEdney-CH Bit Poster

    Messages:
    5
    Hi,

    Thanks for your reply.

    That's exactly what we thought, but the email account has a quota limit of 2GB so not sure where it is getting unlimited from.

    Cheers

    Josh
     
  4. JustinSoul

    JustinSoul Odin Team

    Messages:
    45
    Hello Josh,

    Since you are using Plesk API, PA takes mailbox quota values from `psa.mail` table. In this case, PA works with Mail quota as follows:

    1). If mail quota hasn't been customized during mailbox creation (equal subscription limit) it will be added in DB with `-1`(unlimited) limit. And Plesk API will return `-1` value. It either means that subscription mailbox limit is `unlimited` or mailbox quota is `default`.

    To get default subscription mailbox size limit you can use PA API: http://download1.parallels.com/ppa/11.5/docs/en-US/online/ppa_integration_guide/71676.htm

    For example:

    Code:
    <?xml version='1.0'?>
    <methodCall><methodName>pem.getResourceUsage</methodName>
    <params>
    <param>
        <value>
        <struct>
            <member>
            <name>resource_type_ids</name>
                <value>
                <array>
                 <data>
                    <value>
                    <i4>1000134</i4>
                    </value>
                     </data>
                    </array>
                 </value>
                 </member>
                 <member>
                 <name>subscription_id</name>
                 <value>
                 <i4>8</i4>
                 </value>
            </member>
        </struct>
        </value>
    </param>
    </params>
    </methodCall>
    
    Where is 1000134 is `Mailbox size (in KBytes)` resource id and `8` is subscription id.

    http://prntscr.com/9dda53
    http://prntscr.com/9ddc5q

    2). If you change mailbox quota during mailbox creation (set the limit to less mailbox subscription limit, i.e. non-default ), then it will be displayed in DB and you will get it in API response:

    Example:

    Code:
    [root@pa115mn api]# curl -k https://8.8.8.8:8443/enterprise/control/agent.php -H "Host: 8.8.8.8:8443" -H "HTTP_AUTH_LOGIN: admin" -H "HTTP_AUTH_PASSWD: password" -H "HTTP_PRETTY_PRINT: TRUE" -H "Content-Type: text/xml" -d@get_info.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <packet version="1.6.3.0">
      <mail>
        <get_info>
          <result>
            <status>ok</status>
            <mailname>
              <id>8</id>
              <name>domain2</name>
              <mailbox>
                <enabled>true</enabled>
                <quota>5242880</quota>
              </mailbox>
              <user-guid>abd68b44-6df6-b449-1937-7ecdb5787c9d</user-guid>
              <antivir>off</antivir>
            </mailname>
          </result>
          <result>
            <status>ok</status>
            <mailname>
              <id>3</id>
              <name>hot</name>
              <mailbox>
                <enabled>true</enabled>
                <quota>-1</quota>
              </mailbox>
              <password/>
              <antivir>off</antivir>
            </mailname>
          </result>
          <result>
            <status>ok</status>
            <mailname>
              <id>10</id>
              <name>nine</name>
              <mailbox>
                <enabled>true</enabled>
                <quota>9437184</quota>
              </mailbox>
              <user-guid>5d7ab925-8f85-73e7-b2f6-27b490ab5460</user-guid>
              <antivir>off</antivir>
            </mailname>
          </result>
          <result>
            <status>ok</status>
            <mailname>
              <id>9</id>
              <name>ten</name>
              <mailbox>
                <enabled>true</enabled>
                <quota>-1</quota>
              </mailbox>
              <user-guid>9589e9f2-7b33-e084-9498-2dc6119dfa85</user-guid>
              <antivir>off</antivir>
            </mailname>
          </result>
        </get_info>
      </mail>
    </packet>
    
     

Share This Page