Remote cPanel API calls via XMLAPI to access SpamAssassin
I am trying to create my own frontend to the SpamAssassin module on the cPanel. I want to be able to adjust the blacklist and whitelist, the score to mark an email as spam, and the option to delete the spam. I can see the functions in API1 but not in API2 or UAPI. This is the code so far -
This gives me the white list and black list after some PHP processing. But I can't see how to get the CPANEL VARIABLES into a PHP variable. Thanks for any help
password_auth($domain_username,$domain_password); // logon to the API
$xmlapi->set_debug(0);
// Request the SpamAssassin config from
// the API1 functions (API1 call to SpamAssassin::config)
$result = $xmlapi->api1_query($domain_username, "SpamAssassin", "config", array(domain=>$domain) );
// PROCESS THE $result HTML data
// Request the Email Spam setting from
// the API1 functions (API1 call to Email::has_spam_autodelete)
$result = $xmlapi->api1_query($domain_username, "Email", "has_spam_autodelete", array(domain=>$domain) );
// NOW READ THE spam_auto_delete AND spam_auto_delete_score CPANEL VARIABLES
?>
This gives me the white list and black list after some PHP processing. But I can't see how to get the CPANEL VARIABLES into a PHP variable. Thanks for any help
-
This gives me the white list and black list after some PHP processing. But I can't see how to get the CPANEL VARIABLES into a PHP variable.
Hello, You may receive more user-feedback on this type a question a forum more suited to PHP development questions. The forum here is primarily intended for discussions about the cPanel API itself (e.g. how to obtain the data). Note that you may want to submit a feature request for the additional SpamAssassin functions for cPanel API2/UAPI: Submit A Feature Request Thank you.0 -
I have managed to get the code working so that I can now read the SpamAssassin configuration. But I can't save the information back with the "SpamAsssain-saveconfig" API call. I pass the paremeters that it requires but all that happens is it reurns OK and the configuration in SpamAssassin is reset i.e. the black list and white lists are cleared and the score is set to 5. The parameters I am passing are- blacklist_from1-user@example.com 6 Spam_Rule 3 3 3 whitelist_from1-test@test.co.uk I am using curl to test the api. The curl data for the failing spamassassin api reads -"cpanel_xmlapi_user=test&cpanel_xmlapi_module=SpamAssassin&cpanel_xmlapi_func=saveconfig&cpanel_xmlapi_apiversion=1&arg-0=blacklist_from1-user@example.com&arg-1=6&arg-2=SPAM_RULE 3 3 3&arg-3=whitelist_from1-test@test.co.uk" I have tested my curl commands and I can successfully add an email account with the API function "Email-addpop" and parameters- user 12345luggage! 500 test.com NOTE - the domain name test.com is repacing my actual domain Thanks in advance 0 -
It's important to keep in mind that cPanel API 1 is deprecated. There's actually an internal case open to address the issue with the reset of the user_prefs file when new configuration values are added through the API (case number 48867). However, it's not likely this case will be addressed due to the deprecation of cPanel API 1. It's likely better to develop a custom script that directly modifies the configuration files, or to open a feature request for SpamAssassin API functionality. Thank you. 0
Please sign in to leave a comment.
Comments
3 comments