Description
The Email Queue Manager API allows administrators to manage messages stuck in the Exim mail queue. You can force the delivery of messages that are delayed or permanently delete unwanted/frozen messages from the server.
parameters
Sample Code
For All Email Queue
Use the action_all parameter with either delete or deliver to process the entire queue.
curl --insecure -u "Username:Password" -d "action_all=delete" -X POST "https://HOST:2005/index.php?api=json&act=email_queue_manager"<?php
$user = 'root';
$pass = 'Password';
$host = 'Server IP / Hostname';
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2005/index.php?api=json&act=email_queue_manager';
$post = [
'action_all' => 'delete' // Use 'delete' or 'deliver' to process all
];
// Set the curl parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method.
$res = json_decode($resp, true);
print_r($res);For Single Email Queue
Use the action_single parameter with either delete or deliver to process a specific message ID.
curl --insecure -u "Username:Password" -d "action_single=delete" -d "msg_id=Message_id" -X POST "https://HOST:2005/index.php?api=json&act=email_queue_manager"<?php
$user = 'root';
$pass = 'Password';
$host = 'Server IP / Hostname';
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2005/index.php?api=json&act=email_queue_manager';
$post = [
'action_single' => 'delete', // Use 'delete' or 'deliver'
'msg_id' => 'Message_id'
];
// Set the curl parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method.
$res = json_decode($resp, true);
if (!empty($res['details']['single_log'])) {
print_r($res['details']['single_log']);
} else {
print_r($res['error']);
}