Warning:
The cPanel API 2 system is deprecated. We strongly recommend that you use UAPI instead of cPanel API 2.
This function retrieves a list of the mail directory's subdirectories (boxes) and files.
Warning:
We strongly recommend that you use the following UAPI function instead of this function:
Email::browse_mailbox— This function lists the mail directory's subdirectories (boxes) and files.
When you disable the Receive Mail role, the system disables this function.
WHM API (JSON)
https://hostname.example.com:2087/cpsess##########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=browseboxes&account=user@example.comFor more information, read our Calls from the WHM API documentation.
LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
// Get a list of boxes for user@example.com.
$get_mail_subdir = $cpanel->api2(
'Email', 'browseboxes',
array(
'account' => 'user@example.com',
)
);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.
# Get a list of boxes for user@example.com.
my $get_mail_subdir = $cpliveapi->api2(
'Email', 'browseboxes',
{
'account' => 'user@example.com',
}
);For more information, read our Guide to the LiveAPI System.
cPanel Tag System (deprecated)
- cPanel tags are deprecated. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI.
- cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
- For more information, read our Deprecated cPanel Tag Usage documentation.
Command Line
cpapi2 --user=username Email browseboxes account=user%40example.com dir=maildir showdotfiles=0For more information and additional output options, read our Guide to cPanel API 2 documentation or run the cpapi2 --help command.
Output (JSON)
{
"cpanelresult": {
"apiversion": 2,
"func": "browseboxes",
"data": [
{
"mtime": 1413398866,
"isleaf": 0,
"file": "archive",
"path": "/home/example/mail",
"depth": 2,
"relpath": "/archive",
"ismailbox": 0,
"fullpath": "/home/example/mail/archive",
"type": "dir"
},
{
"mtime": 1412787616,
"isleaf": 0,
"file": "example.tld",
"path": "/home/example/mail",
"depth": 2,
"relpath": "/example.com",
"ismailbox": 0,
"fullpath": "/home/example/mail/example.com",
"type": "dir"
}
],
"event": {
"result": 1
},
"module": "Email"
}
}Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.
If you do not use a parameter, the function returns a list of items in the cPanel account's main mail directory.
| Parameter | Type | Description | Possible values | Example |
|---|---|---|---|---|
account | string | An email address, to limit the function's results. If you do not include this parameter, the function returns data for all of the cPanel account's email addresses. | A valid email address on the cPanel account. | user@example.com |
dir | string | A mail directory name, to limit results to specific directories. If you do not include this parameter, the function returns data for all directories. | A valid directory on the cPanel account. Note:If you pass | maildir |
showdotfiles | Boolean | Whether to include hidden files and directories. This value defaults to |
| 0 |
| Return | Type | Description | Possible values | Example |
|---|---|---|---|---|
mtime | string | The item's modification time. | A time in Unix time format. | 1413398866 |
isleaf | Boolean | Whether the item is a file or a directory. |
| 0 |
file | string | The item's base name. | A valid file or directory name. | archive |
path | string | The item's directory's path. | The item's directory's absolute path. | /home/example/mail |
depth | integer | The directory depth of the item's path. | A positive integer. | 2 |
relpath | string | The item's relative path. | The item's relative path, from the mail directory. | /archive |
ismailbox | Boolean | Whether the item is a mailbox. |
| 0 |
fullpath | string | The item's full path. | The item's absolute path. | /home/example/mail/archive |
type | string | The item type. |
| dir |
reason | string | A reason for failure. Note:This function only returns a | A string that describes the error. | This is an error message. |
result | Boolean | Whether the function succeeded. |
| 1 |