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.

SecurityBasicAuth
Request
query Parameters
account
required
string <email>

An email account that exists on the server.

Example: account=user@example.com
mailbox
required
string

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.

Example: mailbox=INBOX
query
required
string

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

Example: query=savedbefore 52w
Responses
200

HTTP Request was successful.

Response Schema: application/json
object
get/expunge_mailbox_messages
Request samples
whmapi1 --output=jsonpretty \
  expunge_mailbox_messages \
  account='user@example.com' \
  mailbox='INBOX' \
  query='savedbefore 52w'
Response samples
application/json
{
  • "metadata": {
    • "command": "expunge_mailbox_messages",
    • "reason": "OK",
    • "result": 1,
    • "version": 1
    }
}