Mail user account can be created on the specified site. To register new mail account in Plesk database, it is enough to specify some general setup information, namely: the site ID where the mail account will be registered, and the mail account name.

In addition, you can specify various mail account settings (all of them are optional):

  • Mail user access to the account through Plesk GUI
  • Mail box size
  • Mail box alias
  • Mail user permissions
  • Antivirus protection
  • Mail group members (if the account acts as a mail group)
  • Mail groups in which the mail account has membership
  • Files to store in the repository
  • Automatic response messages
  • Mail addresses to which all incoming correspondence will be redirected automatically

A mail account can have all these settings specified, or it can hold just some of them. You can specify these settings when creating a mail account or later (they can be set using the set_prefs operation).

Request Packet Structure

A request XML packet creating a mail account in Plesk database includes the create operation node:

<packet>
 <mail>
  <create>
   ...
  </create>
 </mail>
</packet>

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

image 34500

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 holds a collection of data describing mail accounts to be created. Data type: mailnameFilterType (plesk_mailname.xsd)
  • The site-id node is required. It uniquely identifies the site on which the mail account will be created. Data type: integer.
  • The mailname node is required. It defines the name of a mail account, and a collection of mail account settings (if any specified). Data type: mailnameAddType (plesk_mailname.xsd). See the structure of this node in the Mail Account Settings section.

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

Response Packet Structure

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

image 34503

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 required. It wraps the result of the requested create operation. Data type: operationresultType (common.xsd).
  • The status node is required. It returns the execution status of the create operation. Data type: string. Allowed values: ok | error.
  • The errcode node is optional. It returns an error code when the create operation fails. Data type: unsignedInt.
  • The errtext node is optional. It returns an error message if the create operation fails. Data type: string.
  • The mailname node is optional. It is required if the create operation succeeds. Returns a collection of settings set for the mail account that has just been created. Data type: mailnameType (plesk_mailname.xsd). To see the structure of this node, refer to the Mail User Account Settings section.

Samples

The following packet creates two mail accounts on a single site:

<?xml version="1.0" encoding="UTF-8"?>
<packet>
<mail>
<create>
   <filter>
      <site-id>1</site-id>
      <mailname>
          <name>techdept11</name>
          <mailbox>
                <enabled>true</enabled>
                <quota>1024000</quota>
          </mailbox>
          <forwarding>
                <enabled>true</enabled>
                <address>paul555@testdomain.tst</address>
          </forwarding>
          <alias>michael555</alias>
          <autoresponder>
                <enabled>true</enabled>
                <subject>Your request is accepted</subject>
                <content_type>text/html</content_type>
                <charset>UTF-8</charset>
                <text>Your request will be processed in the nearest 10 days. Thank you.</text>
                <attachment>
                    <tmp-name>/tmp/attachment-file.txt</tmp-name>
                    <file-name>rules.txt</file-name>
                </attachment>
              <forward>techdept@technolux.co.uk</forward>
          </autoresponder>
          <password>
                <value>test123</value>
                <type>plain</type>
          </password>
          <antivir>inout</antivir>
      </mailname>
      <mailname>
          <name>admin11</name>
          <password>
              <value>test</value>
          </password>
          <antivir>inout</antivir>
      </mailname>
   </filter>
</create>
</mail>
</packet>

To create multiple mail accounts on different sites within one packet, use multiple create nodes:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
  <mail>
    <create>
      <result>
        <status>ok</status>
        <mailname>
          <id>5</id>
          <name>techdept11</name>
        </mailname>
      </result>
    </create>
  </mail>
      <result>
        <status>ok</status>
        <mailname>
          <id>6</id>
          <name>admin11</name>
        </mailname>
      </result>
    </create>
  </mail>
</packet>