• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

API :: Enable SpamAssassin for Email account

B

bmwbill42

Guest
Hello.. I have created the following function to enable the spam filter for an account:

function EnableSpam($Username, $DomainName)
{
$req = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?><packet version=\"1.3.4.1\"><spamfilter><set><filter><username>$Username@$DomainName</username></filter><enabled/></set></spamfilter>";
return $this->sendCommand($req);
}

$spam = rpc->EnableSpam(test,test.local);

print_r($spam);

The results of the function are:

Array ( [PACKET] => [SYSTEM] => [STATUS] => error [ERRCODE] => 1014 [ERRTEXT] => Parser error: Cannot parse the XML from the source specified )

After searching through the Plesk 8.4 API documentation I can't seem to find the correct way to enable the SpamAssassin feature on a selected mail account...

Can anyone tell me what I'm doing wrong, it has to be with the XML request format.
 
From the look of the code you haven't closed off the packet node. Also, I believe the version should be at least 1.4.2.0? And the username shouldn't have a domain name...
Code:
<packet version=1.4.2.0>
  <spamfilter>
    <set>
      <filter>
        <username>$Username</username>
      </filter>
      <preferences/>
      <enabled/>
    </set>
  </spamfilter>
</packet>
This from the API-rpc 8.4 guide. Hope it helps.
 
Thanks for pointing that out -- I did forget to close the <packet> node.

with and without the $DomainName appended it succeeds with STATUS => OK, but when I check the account through the GUI the Spam Filter is not enabled for the account...

What am I missing? And if its executing the command with STATUS => OK why is the spam filter not being enabled?
 
Also if I change the packet version all I get are parse errors.. I'm running Plesk 8.4 on CentOS. Do I need to update the API component? Is that updated separately of Plesk itself?
 
Back
Top