Child pages
  • UAPI Functions - Email::add_spam_filter
Skip to end of metadata
Go to start of metadata

Description

This function sets a new minimum Apache SpamAssassin™ spam score threshold value.

Notes:

Important:

In cPanel & WHM version 76 and later, when you disable the SpamFilter role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Email/add_spam_filter?required_score=8.0&account=username%40example.com


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Change the cPanel account's minimum spam score to 8.
$new_spam_score = $cpanel->uapi(
    'Email', 'add_spam_filter',
    array(
        'required_score'    => '8.0',
		'account'			=> 'username@example.com',
         )
);


Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Change the cPanel account's minimum spam score to 8.
my $new_spam_score = $cpliveapi->uapi(
    'Email', 'add_spam_filter',
    {
        'required_score'     => '8.0',
		'account'			=> 'username@example.com',
    }
);


Note:

For more information, read our Guide to the LiveAPI System.

 

 cPanel Template Toolkit
<!-- Change the cPanel account's minimum spam score to 8. -->
[% execute('Email', 'add_spam_filter', { 'required_score' => '8.0' 'account' => 'username@example.com',
 }) %]


Note:

For more information, read our Guide to Template Toolkit documentation. 

 

 Command Line
uapi --user=username Email add_spam_filter required_score=8.0 account=username%40example.com


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
  "messages": null,
  "errors": null,
  "status": 1,
  "data": null,
  "metadata": {
    "transformed": 1
  }
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
required_scorestring

Set a spam score threshold value.

Notes:

  • You must specify a value greater than 0 , and lower than the domain owner's spam score threshold value.
  • In cPanel & WHM version 70 and later, you cannot enter 0 as a value for this parameter.
  • You can retrieve the domain owner‘s spam score threshold value via the  cpuser_spam_auto_delete_score  return from the UAPI  Email::get_spam_settings function .

If you do not specify a value, the function resets the spam score to the default value 5.

A positive integer.

Notes:

  • The default value, 5, is an aggressive spam score.
  • The lower the spam score, the more likely that Apache SpamAssassin will label messages as spam and delete them.
  • Some systems may wish to use a more lenient spam score (for example, 8 or 10). 
8
accountstring

The email account to apply a spam score threshold value.

Note:

We added this parameter in cPanel & WHM version 70.

If you do not specify a value, the function applies the new spam score threshold value to all accounts.

A valid user email account.username@example.com

Returns

This function only returns metadata.