Child pages
  • cPanel API 2 Functions - Email::browseboxes
Skip to end of metadata
Go to start of metadata

Description

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:

Important:

In cPanel & WHM version 76 and later, when you disable the MailReceive role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


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


Note:

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


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.
 
# Get a list of boxes for user@example.com.
my $get_mail_subdir = $cpliveapi->api2(
    'Email', 'browseboxes',
    { 
        'account'          => 'user@example.com', 
    }
);


Note:

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

 

 cPanel Tag System (deprecated)


Warnings:

  • In cPanel & WHM version 11.30 and later, 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=0

Note:

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


Note:

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

Parameters

Note:

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.

Note:

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.

Note:

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