UAPI Functions - Email::browse_mailbox

Description

This function lists the mail directory's subdirectories (boxes) and files.

Examples 


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/execute/Email/browse_mailbox?dir=mail%2Fexample.com

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// List the mail-related subdirectories in mail/example.com.
$list_mailboxes $cpanel->uapi(
    'Email''browse_mailbox',
    array(
        'dir'           => 'mail/example.com',
        )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# List the mail-related subdirectories in mail/example.com.
my $list_mailboxes $cpliveapi->uapi(
    'Email''browse_mailbox',
    {
        'dir'           => 'mail/example.com',
    }
);

 cPanel Template Toolkit

<!-- Get a hash of data, then display the full path for each item. -->
[% data = execute('Email', 'browse_mailbox', { 'dir' => 'mail/example.com' } ) %]
[% FOREACH q = data.fullpath %]
     <p>
         [% q %]
     </p>
[% END %]
  
<!-- Get only the full paths. -->
[% execute('Email', 'browse_mailbox', { 'dir' => 'mail/example.com' } ).data.fullpath %]

 Command Line

uapi --user=username Email browse_mailbox dir=mail%2Fexample.com

 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.

 Output (JSON)

   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{ 
      "transformed":1
   },
   "data":[ 
      
         "isleaf":0,
         "mtime":1414183324,
         "file":"archive",
         "path":"/home/user/mail",
         "depth":2,
         "relpath":"/archive",
         "ismailbox":0,
         "fullpath":"/home/user/mail/archive",
         "type":"dir"
      },
      
         "isleaf":0,
         "mtime":1412787616,
         "file":"example.com",
         "path":"/home/user/mail",
         "depth":2,
         "relpath":"/example.com",
         "ismailbox":0,
         "fullpath":"/home/user/mail/example.com",
         "type":"dir"
      }
   ]
}

 

Note:

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

 

Parameters

Note:

If you do not use any input parameters, 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.

A valid email address on the cPanel account.

 user@example.com 

dir

string

 A mail directory name, to limit results to specific directories. 

A valid directory on the cPanel account.

Note:

 If you pass the default or mail values, 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 absolute path to the item's home directory.

/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 directory path to the item, relative to the mail directory. 

/archive

 ismailbox 

 Boolean 

Whether the item is a mailbox.

  • 1 — Mailbox.
  • 0 — Not a mailbox.

0

fullpath

string

The item's absolute path.

The absolute path to the item.

 /home/example/mail/archive 

type

string

The item type.

  • dir — The item is a directory.
  • file — The item is a file.

dir

 

  • 0 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....