Hi guys, I have tested this simple code: Code: $params = array( 'server_id' => $ServerId, 'domain' => $domain['domain'], 'active' => 'y'); try{ // Get the domain name ID $record = $client->mail_domain_get_by_domain($this->getSession(), $domain['domain']); // Create the mail domain if(empty($record['domain_id'])){ $domainId = $client->mail_domain_add($this->getSession(), $clientId, $params); }else{ $domainId = $record['domain_id']; } echo $domainId; } catch ( SoapFault $e ) { throw new Exception("There was a problem with the Mail Domain creation: " . $e->getMessage() . " - " . __METHOD__ . " - Paramenters: " . json_encode($params) , "3506"); } If you execute this code you'll get the exception domain_error_unique why this happens?
Either there is already a email domain with that value or the domain variable is empty or a similar problem.
Take a look at the mail_domain table in the ispconfig database with phpmyadmin to ensure that it is really empty.
It's not important if there is already a domain saved in the db because I check if the domain exist before.
It is important if there is a domain in the DB as you cant add a duplicate domain and the error that you get tells you that there is already that domain in the mail_domain table. So check with phpmyadmin if the mail_domain table is empty or not.
As you can see in the code posted I check if the domain exists in the db using the mail_domain_get_by_domain method. If the domain exists the creation of the new mail domain is not a problem because the condition check if it exists or not. So if the problem is not of the mail_domain_add method maybe the problem is mail_domain_get_by_domain that doesn't get the domain from the db.
Try: $record = $client->mail_domain_get($this->getSession(), array('domain' => $domain['domain'])); if(coun($record) > 0) { echo 'domain exists'; } else { echo 'domain does not exist'; }
Then it might be that the variable $domain['domain'] does not contain the domain, as the query functions for mail domains work properly on my servers.