Use the set_prefs operation to set mail service preferences on the specified sites.

Request Packet Structure

A request XML packet setting mail service preferences for the specified sites includes the set_prefs operation node:

<packet>
 <mail>
  <set_prefs>
   ...
  </set_prefs>
 </mail>
</packet>

The set_prefs node does not have a separate data type, it is nested within the MailTypeRequest type (mail_input.xsd). The set_prefs node has the following graphics representation:

image 34538

Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_input.svg.

  • The filter node is required. It specifies a list of sites on which mail service settings are modified. Data type: none.
  • The site-id node is optional. It specifies the identifier of the site on which mail service settings are modified. Data type: integer.
  • The prefs node is required. It specifies a collection of mail service preferences that will be set for the specified sites. Data type: MailPreferences. The structure of this node is described in the Mail Service Settings section.

Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.

Response Packet Structure

The set_prefs node of the response packet is structured as follows:

image 34541

Note: The interactive schema navigator for all response packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_output.svg.

  • The result node is optional. It wraps the result of the requested set_prefs operation. Data type: resultType (common.xsd).
  • The status node is required. It returns the execution status of the set_prefs operation. Data type: string. Allowed values: ok | error.
  • The errcode node is optional. It is used to return an error code if the set_prefs operation fails. Data type: unsignedInt.
  • The errtext node is optional. Can be used to return an error message if the set_prefs operation fails. Data type: string.
  • The site-id node is optional. Returns the identifier of the site on which mail service settings have been modified. Data type: integer.

Samples

Setting Mail Service Preferences under Plesk Administrator

Plesk Administrator can set mail service preferences for all sites registered in Plesk.

Setting mail service preferences for particular sites

The following packet sets mail service preferences for three sites:

<packet>
<mail>
<set_prefs>
   <filter>
      <site-id>1</site-id>
      <site-id>2</site-id>
      <site-id>3</site-id>
   </filter>
   <prefs>
      <nonexistent-user>
          <reject/>
      </nonexistent-user>
      <mailservice>false</mailservice>
   </prefs>
</set_prefs>
</mail>
</packet>

Response:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
  <mail>
    <set_prefs>
      <result>
        <status>ok</status>
        <site-id>1</site-id>
      </result>
      <result>
        <status>ok</status>
        <site-id>2</site-id>
      </result>
      <result>
        <status>ok</status>
        <site-id>3</site-id>
      </result>
    </set_prefs>
  </mail>
</packet>

To set different settings for different sites within a single packet, use multiple set_prefs elements:

Setting mail service preferences for all sites registered in Plesk

If the filter is empty, the specified settings will be applied to all sites registered in Plesk:

<packet version="1.6.7.0">
<mail>
<set_prefs>
   <filter/>
   <prefs>
      <webmail>true</webmail>
   </prefs>
</set_prefs>
</mail>
</packet>

Response:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
  <mail>
    <set_prefs>
      <result>
        <status>ok</status>
        <domain_id>1</domain_id>
      </result>
      <result>
        <status>ok</status>
        <domain_id>2</domain_id>
      </result>
      <result>
        <status>ok</status>
        <domain_id>3</domain_id>
      </result>
      <result>
        <status>ok</status>
        <domain_id>4</domain_id>
      </result>
    </set_prefs>
  </mail>
</packet>

Setting Email Service Settings under customer

All the use cases of the set_prefs operation node for customers are similar to those for Plesk Administrator. The only difference is that an empty filter means that the specified settings will be applied to all sites belonging to the customer sending the packet:

<packet version="1.6.7.0">
<mail>
<set_prefs>
   <filter/>
   <prefs>
     <webmail>true</webmail>
   </prefs>
</set_prefs>
</mail>
</packet>

Response:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
  <mail>
    <set_prefs>
      <result>
        <status>ok</status>
        <domain_id>1</domain_id>
      </result>
      <result>
        <status>ok</status>
        <domain_id>2</domain_id>
      </result>
      <result>
        <status>ok</status>
        <domain_id>3</domain_id>
      </result>
      <result>
        <status>ok</status>
        <domain_id>4</domain_id>
      </result>
    </set_prefs>
  </mail>
</packet>