Description

This function retrieves a list of the mail directory's subdirectories (boxes) and files.


We strongly recommend that you use the following UAPI function instead of this function:

Examples




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.com



$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', 
    ) 
);

 



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', 
    }
);

 




cpapi2 --user=username Email browseboxes account=user%40example.com dir=maildir showdotfiles=0


For more information and additional output options, read our Guide to cPanel API 2 documentation or run the cpapi2 --help command.  




{
  "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"
  }
}



Parameters

If you do not use a parameter, the function returns a list of items in the cPanel account's main mail directory.


ParameterTypeDescriptionPossible valuesExample
accountstring

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
dirstring

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.

If you pass default or mail, the function lists information for all mail directories. 


maildir
showdotfilesBoolean

Whether to include hidden files and directories.

This value defaults to 0.

  • 1 — Include hidden items.
  • 0 — Do not include hidden items.
0

Returns

ReturnTypeDescriptionPossible valuesExample
mtimestringThe item's modification time.A time in Unix time format.
1413398866
isleafBooleanWhether the item is a file or a directory.
  • 1 — File.
  • 0 — Directory.
0
filestringThe item's base name.A valid file or directory name.archive
pathstringThe item's directory's path.The item's directory's absolute path./home/example/mail
depthintegerThe directory depth of the item's path.A positive integer.2
relpathstringThe item's relative path.The item's relative path, from the mail directory./archive
ismailboxBooleanWhether the item is a mailbox.
  • 1 — Mailbox.
  • 0 — Not a mailbox.
0
fullpathstringThe item's full path.The item's absolute path./home/example/mail/archive
typestringThe item type.
  • dir — The item is a directory.
  • file — The item is a file.
dir
reasonstring

A reason for failure.

This function only returns a reason value if it failed. 


A string that describes the error.

This is an error message.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1