Description

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

Examples 




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




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

 



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

 



<!-- 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 %]

 



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



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



Parameters

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

A valid email address on the cPanel account.

user@example.com
dirstring

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

A valid directory on the cPanel account.

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

/home/example/mail
depthintegerThe directory depth of the item's path.A positive integer.2
relpathstringThe item's relative path.The directory path to the item, relative to the mail directory./archive
ismailboxBooleanWhether the item is a mailbox.
  • 1 — Mailbox.
  • 0Not a mailbox.
0
fullpathstringThe item's absolute path.The absolute path to the item./home/example/mail/archive
typestringThe item type.
  • dir — The item is a directory.
  • file — The item is a file.
dir