Using API to pull email domains

Discussion in 'Developers' Forum' started by [email protected], Apr 10, 2014.

  1. david_hitt@lionlike.com

    [email protected] New Member

    I'm trying to use the API to pull all email domains owned by a specific client. The sys_groupid in the mail_domains table seems to be the relationship to client accounts (a sys_groupid value consistant with a specific client)... however, the sys_groupid of all clients in the client table is 1 - none are unique. The ISPConfig control panel at :8080 does relate mail domains to the appropriate owner, but how is this relationship made if not by the sys_groupid?

    Thanks!
     
  2. david_hitt@lionlike.com

    [email protected] New Member

    Nevermind... solution found

    sys_groupid is stored in the sys_group table that relates groupid to client. So the code to link client, to group id, to mail domains is as follows:

    PHP:
    $sysname mysql_fetch_assoc(mysql_query("SELECT sysname FROM client WHERE id=".$_GET['oid'].""));
    $client = new SoapClient(null, array('location' => $soap_location,'uri'=>$soap_uri,'trace' => 1,'exceptions' => 1));
    try {
      
    $session_id $client->login($username,$password);
      
    $client_data $client->client_get($session_id, array('username' => $sysname['sysname']));
      
    $client_id $client_data[0]['client_id'];
      
    $groupid $client->client_get_groupid($session_id$client_id);
      
    $mail_record $client->mail_domain_get($session_id, array('sys_groupid' => $groupid));
      foreach (
    $mail_record as $mail) {
        echo 
    $mail['domain'];
      }
      
    $client->logout($session_id);
    }
    catch (
    SoapFault $e) {
      
    //echo $client->__getLastResponse();
      
    die('SOAP Error: '.$e->getMessage());
    }
     

Share This Page