List emails using cPanel API2

0

I am working with the cPanel API and I want to list all the emails with the assigned tray space and how much they have consumed so far ... Everything works for me without problems but my question / problem lies in the following:

In the documentation it says that you have to pass as a domain parameter, so I do a query, I do a count to know how many domains there are in total and then I work it in a while ... Inside this while I have the Consult the API for what I need but, when you print it makes it double, understand, like this:

  

[email protected]

     

[email protected]

     

[email protected]

     

[email protected]

     

[email protected]

     

[email protected]

     

[email protected]

     

[email protected]

How do I avoid that? I attach my codes:

<?php
define('cP_user', '*******');
define('cP_pass', '********');
define('cp_svIP', '***.***.***.***');
define('cP_port', '2083');

// xml_api.php es la que se encuentra en la repo oficial de cPanel
require('inc/xml_api.php');

$xmlapi  = new xmlapi(cp_svIP);
$xmlapi -> set_port(cP_port);
$xmlapi -> password_auth(cP_user,cP_pass);
$xmlapi -> set_debug(1);


$get_domain_list = $xmlapi->api2_query(
//    cP_user, 'DomainLookup', 'getmaindomain'      --> dominio principal
    cP_user, 'DomainLookup', 'getbasedomains'       //--> todos los dominios
);

$total_domains = count($get_domain_list->data);

$k = 0;
while ($k < $total_domains) {

    $get_email_list = $xmlapi->api2_query(
        cP_user, 'Email', 'listpopswithdisk',
        array( 'domain' => $get_domain_list->data[$k]->domain, )
    );

    $total_emails = count($get_email_list->data);

    $i = 0;
    while ($i < $total_emails) {
        echo 'correo: '. $get_email_list->data[$i]->email;
        echo ' | Espacio utilizado: '. $get_email_list->data[$i]->humandiskused;
        echo ' | Capacidad bandeja: '. $get_email_list->data[$i]->humandiskquota .'<br/>';
        $i++;
    }

    $k++;
}
?>
    
asked by KuroNeko 05.03.2018 в 19:25
source

0 answers