Adding Pattern

Use the add-pattern operation to add new patterns to a specified list of a specified user (Administrator or mailbox owner). For information on patterns refer to the Defining Pattern section.

In this chapter:

Request Packet Structure

Response Packet Structure

Samples

 

Request Packet Structure

A request XML packet adding a pattern includes the add-pattern operation node:

<packet>
<spamfilter>
<add-pattern>
...  
</add-pattern>
</spamfilter>
</packet>

 

The add-pattern node is presented by the SpamFilterAddPatternInputType type (spamfilter.xsd), and its graphical representation is as follows:

  • The filter node is required. It specifies the filtering rule. Data type: SpamPatternFilter (spamfilter.xsd).
  • The list node is required. It specifies the type of the list. For information on list types, refer to the Types of Server Lists and Types of Lists available for Mailbox Owners sections. Data type: SpamListType (spamfilter.xsd). Allowed values: black | white | unblack | unwhite.
  • The username node is required.It specifies the name of a SpamAssassin user. You can specify e-mail address of a mailbox owner, or the 'admin' value. To access server black (white) lists, you should set 'admin' as a value for this node. Data type: string.
  • The spamfilter-id node is required. It specifies the ID of a SpamAssassin user. Data type: integer.

Remarks

You can add patterns to multiple users in a single packet. Add as many add-pattern operations as the number of different users to be affected.

<add-pattern>
   ...
</add-pattern>
   ...
<add-pattern>
   ...
</add-pattern>

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

 

 

Response Packet Structure

The add-pattern node of the output XML packet is presented by type SpamFilterAddPatternOutputType (spamfilter.xsd) and structured as follows:

  • The result node is required. It wraps the response retrieved from the server. Data type: ResultFilterType (common.xsd).
  • The status node is required. It specifies the execution status of the add-pattern operation. Data type: string. Allowed values: ok | error.
  • The errcode node is optional. Is returns the error code if the add-pattern operation fails. Data type: integer.
  • The errtext node is optional. It returns the error message if the add-pattern operation fails. Data type: string.
  • The filter-id node is optional. It holds the filtering rule parameter. For information, refer to the Available Filters section. Data type: anySimple.
  • The id node is optional. It returns the ID of the added pattern if the operation succeeds. Data type: integer.

 

 

Samples

Adding a pattern

This request packet adds pattern *@spam.net to the server black list.

<packet>
<spamfilter>
<add-pattern>
   <filter>
      <pattern>*@spam.net</pattern>
   </filter>
   <list>black</list>
   <username>admin</username>
</add-pattern>
</spamfilter>
</packet>

Response:

<packet>
<spamfilter>
<add-pattern>
   <result>
      <status>ok</status>
      <filter-id>*@spam.net</filter-id>
      <id>17</id>
   </result>
</add-pattern>
</spamfilter>
</packet>

 

If the SpamAssassin service is restricted by Plesk license key, or a user does not have access to SpamAssassin management, the response is as follows:

<packet>
<spamfilter>
<add-pattern>
   <result>
      <status>error</status>
      <errcode>1006</errcode>
      <errtext>Permission denied.</errtext>
      <filter-id>*@spam.net</filter-id>
   </result>
</add-pattern>
</spamfilter>
</packet> 
Adding multiple patterns

This request packet adds patterns *@spam.net and spam@mailme.net to the black list of mailbox mybox@site.com.

<packet>
<spamfilter>
<add-pattern>

   <filter>
      <pattern>*@spam.net</pattern>
      <pattern>spam@mailme.net</pattern>
   </filter>
 
<list>black</list>
 
<username>mybox@site.com</username>
</add-pattern>
</spamfilter>
</packet>

Response (if the pattern *@spam.net is already present in the black list of the mailbox owner, the response can look as follows):

<packet>
<spamfilter>
<add-pattern>
   <result>
      <status>error</status>
      <errcode>1007</errcode>
      <errtext>The inserted data already exists.</errtext>
      <filter-id>*@spam.net</filter-id>
   </result>
   <result>
      <status>ok</status>
      <filter-id>spam@mailme.net</filter-id>
      <id>15</id>
   </result>
</add-pattern>
</spamfilter>
</packet>

 

 

Leave your comments on this page

Leave your feedback or question on this documentation topic below. For technical assistance, contact your hosting service provider or submit a request to Plesk support. Suggest new features for Plesk here. Discuss general questions on the Plesk forum. All offtopic comments will be removed.