Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function marks the selected mail messages as deleted.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Mailboxes/expunge_mailbox_messages?account=example&mailbox=INBOX.user@example_com&query=savedbefore%2052w

Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Mark the selected mail messages as deleted.
$Mailboxes_get_mailbox_status = $cpanel->uapi(
    'Mailboxes', 'expunge_mailbox_messages'
);

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.
 
# Mark the selected mail messages as deleted.
my $Mailboxes_get_mailbox_status = $cpliveapi->uapi(
    'Mailboxes', 'expunge_mailbox_messages',
);

Note:

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

 cPanel Template Toolkit
<!-- Mark the selected mail messages as deleted. -->
[% data = execute( 'Mailboxes', 'expunge_mailbox_messages' ); %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 Command Line
uapi --user=username Mailboxes expunge_mailbox_messages account=example mailbox=INBOX.user@example_com query="savedbefore 52w"

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
 
{
  "messages": null,
  "errors": null,
  "status": 1,
  "metadata": {
  },
  "data":null
}


Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
accountstring

Required

The email account's name.

  • A valid email account that exists on the server.
  • The cPanel user's account name.

    Note:

    _mainaccount is an alias represents the cPanel user's mailbox (For example, _mainaccount@example.com represents the example mailbox).

user@example.com

example

_mainaccount@example.com

mailboxstring

Required

The mailbox to operate on.

A valid mailbox folder on the server that the user owns that uses the following format:

The mailbox folder name, a period (.), and the address with and underscore (_) instead of a period (.).

Notes:

INBOX.user@example_com

querystring

Required

The dovecot query to execute.

Notes:

  • The query parameter prevents accidental removal of all messages in the mailbox
  • For more information, read Dovecot's Search Query documentation.
 A valid Dovecot search query. savedbefore 52w

Returns

This function only returns metadata.