Child pages
  • UAPI Functions - SpamAssassin::update_user_preference
Skip to end of metadata
Go to start of metadata

Description

This function sets the Apache SpamAssassin™ settings for the account.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/SpamAssassin/update_user_preference?preference=score&value=ACT_COW_CAPS%205.0


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.

// Set the Apache SpamAssassin™ settings for the account.
$sa_settings = $cpanel->uapi(
    'SpamAssassin', 'update_user_preference',
    array(
        'preference' => 'score',
		'value'      => 'ACT_NOW_CAPS 5.0'
         )
);


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.

# Set the Apache SpamAssassin™ settings for the account.
my $sa_settings = $cpliveapi->uapi(
    'SpamAssassin', 'update_user_preference',
    {
        'preference' => 'score',
		'value'      => 'ACT_NOW_CAPS 5.0'
    }
);


Note:

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

 

 cPanel Template Toolkit
<!-- Set the Apache SpamAssassin™ settings for the account. -->
[% execute('SpamAssassin', 'update_user_preference', { 'preference' => 'score', 'value' => 'ACT_NOW_CAPS 5.0' }) %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]


Note:

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

 

 Command Line
uapi --user=username SpamAssassin update_user_preference preference=score value-0="ACT_NOW_CAPS 5.0"


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. 

 Output (JSON)
{  
   "data":{  
      "score":[  
         "ACT_NOW_CAPS 5.01"
      ],
      "required_score":[  
         "5.0"
      ],
      "whitelist_from":[  
         "username@example.com"
      ],
      "blacklist_from":[  
         "username@example.com"
      ]
   },
   "messages":null,
   "errors":null,
   "metadata":{  

   },
   "status":1
}


Note:

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

Parameters

Warning:

If you enter a value for the preference parameter, but you do not define a value for the value parameter, the function will remove any previous settings.


ParameterTypeDescriptionPossible valuesExample
preferencestring

The variable that you want to manipulate.

Required.

  • score

  • required_score
  • whitelist_from
  • blacklist_from

Note:

You can only choose one of these possible values per call.

score

valuestring

The value for the preference of the variable that you want to manipulate.

  • A valid "TEST_NAME SCORE" when the value of the preference parameter is score.

    Notes:

    • TEST_NAME represents the symbolic name of the test. For list of symbolic test names, run the UAPI SpamAssassin::get_symbolic_test_names function.

    • SCORE represents the floating-point value that SpamAssassin assigns to the mail when the test result is true. The score value must be greater than 0, and less than 1000.

    • To enter multiple test names, use the value-0="TEST_NAME SCORE" value-1="TEST_NAME SCORE" format.
  • A valid floating-point number if the value of the preference parameter is required_score.
  • A valid email address if the value of the preference parameter is whitelist_from or blacklist_from.

  • ACT_NOW_CAPS 1
  • 5.0
  • username@example.com


Returns

ReturnTypeDescriptionPossible valuesExample
scorearray of strings

The symbolic test name and score.

The function returns this value in the score array.

A valid test name and score.

ACT_NOW_CAPS 1
required_scorearray of floating-point numbers

The score to mark a message as spam. The system considers mail that matches this score to be spam.

The function returns this value in the required_score array.

A valid floating-point number.

5.0
whitelist_fromarray of strings

The email addresses on the whitelist.

The function returns this value in the whitelist_from array.

A valid email address.

username@example.com
blacklist_fromarray of strings

The email addresses on the blacklist.

The function returns this value in the blacklist_from array.

A valid email address.

username2@example.com

Note:

Additional customizations may appear in the returns. For more information, read the Apache SpamAssassin configuration file documentation.