Hello, I would like to list all mail domains using ISPConfig remote API. In this forum, I found a way to list websites domains. But I didn't find how to do the same for mail domain, even in the API documentation. The only way I see is to set a variable to 1 then loop incrementing it to 1 on every iteration and check if there is a domain with this ID but this method doesn't look like very safe. Does someone have a method to list mail domains using remote API? Also, I would like to get the associated DNS zone with this mail domain. Thanks.
You get all records by passing -1 to one of the *_get functions. Example: Code: $all_mail_domains = $client->mail_domain_get($session_id,-1);
Thanks! Now I am trying to get the associated dns zone. I tried this: Code: <?php require 'soap_config.php'; $client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri, 'trace' => 1, 'exceptions' => 1)); try { if($session_id = $client->login($username, $password)) { echo 'Logged successfull. Session ID:'.$session_id."\n"; } //* Set the function parameters. $domain_id = -1; $mail_domains = $client->mail_domain_get($session_id, $domain_id); foreach ($mail_domains as $domain) { $domain_name = $domain['domain']; print("Domain : ".$domain_name."\n"); $zone = $client->dns_zone_get($session_id, array('origin' => $domain_name)); print_r($zone); print("\n"); } if($client->logout($session_id)) { echo "Logged out.\n"; } } catch (SoapFault $e) { echo $client->__getLastResponse(); die('SOAP Error: '.$e->getMessage()); } ?> I found this method of search on this script : https://github.com/dmgeurts/isp-mailConfig File include/classes/AutoConfig.php Doesn't it apply for DNS zones?
You missed in the code that a domain in DNS ends with a dot while a domain in the email system does not end with a dot. Change the line: $domain_name = $domain['domain']; to: $domain_name = $domain['domain'].'.';
OK thanks! Looks like the API brings me from question to other question... If I read right examples, to add a DNS record, I have to specify the client ID. Is it OK to use the "sys_userid" from the DNS zone or is it another ID? Thanks again for all your help.
No, you have to use the client_id from client table. There is a api function t et it based on the group_id