cPanel API 2 Functions - Email::browseboxes

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:

  • Email::browse_mailbox — This function lists the mail directory's subdirectories (boxes) and files.

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=

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

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

 cPanel Tag System (deprecated)

Warning:

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.

cPanel API 2 calls that use cPanel tags vary widely in code syntax and in their output. For more information, read our Deprecated cPanel Tag Usage documentation. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI.

 

 Command Line

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

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

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 default ormail, the function lists information for all mail directories. 

 maildir

 showdotfiles 

 Boolean 

 Whether to include hidden files and directories.

 This value defaults to 0.

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

 0

 

Returns

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.

  • 1 — File.
  • 0 — 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.

  • 1 — Mailbox.
  • 0 — Not 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 — The item is a directory.
  • file — The item is a file.

 dir

 reason

 string

 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.

 result

 Boolean 

 Whether the function succeeded.

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

 1

 

  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....