latestOpenAPI 3.0.2cPanel License2026-08-106251554.3 MB

3da41671c02c

Mail
cPanel Account Mail Management

Remove email account messages by Dovecot query

This function removes mail messages from a cPanel account that you select with a query.

Important:

When you disable the Receive Mail role, the system disables this function.

get/expunge_mailbox_messages

Query parameters

accountstring email required
Example:user@example.com

An email account that exists on the server.

mailboxstring required
Example:INBOX

A mailbox name on the account.

Note:

Because you cannot escape wildcard characters such as (*), we recommend that you use functions that use the mailbox_guid parameter instead. For example, the WHM API 1 expunge_messages_for_mailbox_guid function.

querystring required
Example:savedbefore 52w

A Dovecot search query to select which messages you wish to remove from the mailbox.

Response

HTTP Request was successful.

Example response

{
  "metadata": {
    "command": "expunge_mailbox_messages",
    "reason": "OK",
    "result": 1,
    "version": 1
  }
}