JSON for CMD_EMAIL_POP

Version 1.52

Feature
Finished

This change allows the ability to use CMD_EMAIL_POP?domain=domain.com&json=yes to get JSON output. The output will vary quite a bit depending on several conditions, so be sure to test all conditions, as each DA box might give different output. Top level variables: "clean_forwarders_on_email_delete": set to 1 if enabled https://www.directadmin.com/features.php?id=1398 "count_pop_usage": set to 1 if enabled: https://www.directadmin.com/features.php?id=641 "EMAIL_MESSAGE": this will usually be an empty string "" but if it isn't, it should be a general info string, shown to the User, eg: "Until the cache is created, the values may not be correct. Refresh the page in 1 minute." "pop_disk_usage_cache": set to 1 if enabled: https://www.directadmin.com/features.php?id=642 "pop_disk_usage_true_bytes": set to 1 if enabled: https://www.directadmin.com/features.php?id=1735 If enabled, then you'll need to show apparent_usage instead of usage (see below) "user_can_set_email_limit": set to 1 if enabled: https://www.directadmin.com/features.php?id=1373 "block_cracking_unblock": set to 0, 1 or 2, depending on: https://www.directadmin.com/features.php?id=1645 "hide_outlook": usually 0, but if 1, don't show the outlook column with a url like: CMD_EMAIL_REG/${domain}/${usernmae}/${login}/outlook_admin.reg "purge_select": select box data for the account purge tool. "when_select": "select box data for the "when" portion of the purge (eg: all or messages older than x days, etc..) "emails": main data for all email account, including system account. This returns a "table" version of the json, so has the standard "info" sub-array giving info about rows, column names, etc.. Because it's a standard table, you can search, sort and filter, like a normal table. =========== A sample row from emails might look like: "4": { "account": "user@domain.com", "login": "user@domain.com", "usage": { "apparent_usage": "12.023", "imap_bytes": "25047040", "quota": "30", "usage": "23.886", "webmail_bytes": "0.000000" }, "sent": { "send_limit": "42", "sent": "1" }, "suspended": "no:blockcracking:change_pass" }, where this data can vary a lot depending on the values of the global settings above. "login": this is straightforward, but will be just "user" for the syseem account. "usage": This is dependant on "count_pop_usage", and if count_pop_usage=0, then only "quota" is shown, or nothing at all for system account. "sent": if user_can_set_email_limit=0, this will not appear. "suspended": usually "yes" or "no", but can be "no:blockcracking:change_pass" or "no:blockcracking:no_unblock", where it means the account is blocked via BlockCracking. If change_pass, then you can offer info that it can be unblocked by changing the password for this account, but no_unblock cannot be unblocked. unblocking info: https://www.directadmin.com/features.php?id=1645 Manually blocking a User can be done by adding them to /var/spool/exim/blocked_authenticated_users in the format: user@domain.com:1501988529 where the right part is the timestamp when they got blocked. =========== IMPORTANT: when coding with this json output be sure to test all of the directadmin.conf settings, off/on etc, and scenarios to ensure you're handling all cases. Different servers will have different settings, thus different output.

Interested to try DirectAdmin? Get a 30-day Free Trial!