zimbra-api / soap-api

Zimbra SOAP client in PHP language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ServerException when using getdomain() if domain does not exist in zimbra server

Zelrone opened this issue · comments

I tried using getdomain() function of Zimbra API and it works well when I provide the domain name that exists in the mail server, but if I try and give a domain name that is not added in the mail server its gives me the following error message in laravel.

ServerException in RequestException.php line 113:
Server error: `POST https://mail.fisquare.net:7071/service/admin/soap` resulted in a `500 Server Error` response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"><change tok (truncated...)

I am using the function as below :

           $api = \Zimbra\Admin\AdminFactory::instance(env("ZIMBRA_URL"));
           $api->auth(env("ZIMBRA_USER_ID"), env("ZIMBRA_PASSWORD"));

            $domain = new \Zimbra\Admin\Struct\DomainSelector(\Zimbra\Enum\DomainBy::NAME(), $domainName);
            $data = $api->getDomain($domain);
            $ret["status"] = "success";
            $ret["msg"] = "Domain found";
            $ret["domainId"] = $data->domain->id;

This code works well when the domain exists but for a domain that is not in the mail server, I am getting the above exception. Can someone tell me if I am doing something wrong?