data['domain'] = $this->getWhmcsParamByKey('domain'); $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0'); try { $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword')); $domainID = $api->getDomainId($this->data['domain']); } catch (KerioApiException $error) { logModuleCall( 'kerioEmail', __FUNCTION__, $error, 'Debug Error', $error->getMessage() ); return ['error' => $error->getMessage()]; } $fields = array( "id", "loginName" ); $accounts = $api->getUsers($fields,$domainID); $api->logout(); /** * available accounts */ foreach($accounts as $account) { $this->availableValues['mailbox'][$account['loginName']] = $account['loginName'] . '@' . $this->data['domain']; } } public function create() { $domain = $this->getWhmcsParamByKey('domain'); $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0'); try { $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword')); $domainID = $api->getDomainId($domain); } catch (KerioApiException $error) { logModuleCall( 'kerioEmail', __FUNCTION__, $error, 'Debug Error', $error->getMessage() ); return ['error' => $error->getMessage()]; } try { $result = $api->createAlias($domainID, $this->formData['aliasName'], $this->formData['mailbox'] . '@' . $domain); } catch (KerioApiException $error) { logModuleCall( 'kerioEmail', __FUNCTION__, $error, 'Debug Error', $error->getMessage() ); return ['error' => $error->getMessage()]; } return (new HtmlDataJsonResponse())->setMessageAndTranslate('emailAliasHasBeenCreated')->setStatusSuccess(); } public function update() { // TODO: Implement update() method. } }