Child pages
  • UAPI Functions - BoxTrapper::delete_messages
Skip to end of metadata
Go to start of metadata

Description

This function deletes messages in the BoxTrapper queue.

Important:

When you disable the MailReceive role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/BoxTrapper/delete_messages?email=user@example.com&queuefile=example.msg&all_like=1


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.
// Delete the messages in the BoxTrapper queue.
$delete_messages = $cpanel->uapi(
    'BoxTrapper', 'delete_messages',
    array(
        'email'     => 'user@example.com',
        'queuefile' => 'example.msg',
		'all_like'  => '1',
    )
);


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.
 
# Delete the messages in the BoxTrapper queue.
my $delete_messages = $cpliveapi->uapi(
    'BoxTrapper', 'delete_messages',
    {
        'email'     => 'user@example.com',
        'queuefile' => 'example.msg',
		'all_like'  => '1',
    }
);


Note:

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

 cPanel Template Toolkit
<!-- delete the messages in the BoxTrapper queue. -->
[% SET result = execute( 'BoxTrapper', 'delete_messages',
    {
     	email     => 'user@example.com',
        queuefile => 'example.msg',
        all_like  => '1',
    });
%]
[% IF result.status %]
[%   FOREACH item IN result.data %]
     [% IF item.failed %]
     Failed to delete the message with error: [% item.reason %].
     [% ELSIF item.warning %]
     Successfully deleted all messages with sender [% item.email %], but there were other non-critical failure: [% item.reason %]
     [% ELSE %]
     Successfully deleted all messages with sender: [% item.email %].
     [% END %]
[%   END %]
[% ELSE %]
     Failed: [% result.errors.join(', ') %]
[% END %]


Note:

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

 Command Line
uapi --user=username BoxTrapper delete_messages email=user@example.com queuefile=example.msg all_like=1


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. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
   {
      "data": [
         {
            "email" : "user@example.com",
            "operator" : "delete",
			"matches" : [
				"example.msg"
				],
         }
      ],
      "errors": null,
      "messages": null,
      "metadata": {
         "transformed": 1
      },
      "status": 1,
      "warnings": null
   }


Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
email

string

Required

The account's email address.

Warning

If you call this function in Webmail, the system ignores this parameter and defaults to the currently-authenticated email address.

A valid email address on the cPanel account.user@example.com
queuefilestring

Required

The filename of the email message who's sender to delete.

Note:

To delete multiple email message senders, duplicate the parameter name.

A valid filename.

example.msg
all_likeBoolean

Whether to delete all messages that resemble the queuefile parameter's value.

This parameter's value defaults to 0.

  • 1 — Delete all similar messages.
  • 0 — Don't delete all similar messages.
1

Returns

ReturnTypeDescriptionPossible valuesExample

array of hashesAn array of hashes of deleted email message informationThis array of hashes contains the email, operator, and matches returns.

email

string

The deleted email message's sender.

The function returns this value in the unnamed array of hashes.

A valid email address.user@example.com

operator

string
The operation that the system performed.
The function returns this value in the unnamed array of hashes.
delete is the only possible value.delete

matches

array
An array of messages that the system deleted.

The function returns this value in the unnamed array of hashes.

An array of deleted message files.example.msg

failed

Boolean

Whether the system failed to delete the messages.

Note:

The function only returns this value if it doesn't delete the message.

The function returns this value in the unnamed array of hashes.

1 is the only possible value.1

reason

string

A message about the failure or the warning.

Note:

The function only returns this value if it doesn't delete the message or experiences issues when it deletes the message.

The function returns this value in the data array of hashes.

A string that describes the failure or warning.
(XID d9myfd) The system failed to locate the requested message:

warning

Boolean
Whether the system experienced issues when it deleted the message.

Note:

The function only returns this value if it experiences issues when it deletes the message.

The function returns this value in the unnamed array of hashes.

1 is the only possible value.
1