|
|
@@ -88,12 +88,45 @@ class AddEmailAliasDataProvider extends BaseDataProvider
|
|
|
$productManager = new ProductManager();
|
|
|
$productManager->loadByHostingId($hid);
|
|
|
|
|
|
+ $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
+ try {
|
|
|
+ $api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
|
|
|
+ $domains = $api->getDomains(['id','name']);
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $error,
|
|
|
+ 'Debug Error',
|
|
|
+ $error->getMessage()
|
|
|
+ );
|
|
|
+ return ['error' => $error->getMessage()];
|
|
|
+ }
|
|
|
+ foreach($domains as $maildomain) {
|
|
|
+ if(($maildomain['name']) === $this->formData['domain']){
|
|
|
+ $this->maildomainID = $maildomain['id'];
|
|
|
+ $this->maildomain = $maildomain['name'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ $result = $api->createAlias($this->maildomainID, $this->formData['aliasName'], $this->formData['mailbox'] . '@' . $this->maildomain);
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $error,
|
|
|
+ 'Debug Error',
|
|
|
+ $error->getMessage()
|
|
|
+ );
|
|
|
+ return ['error' => $error->getMessage()];
|
|
|
+ }
|
|
|
+
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|
|
|
__FUNCTION__,
|
|
|
$this->formData,
|
|
|
'Debug Error',
|
|
|
- $this->getWhmcsParamByKey('domain')
|
|
|
+ $result
|
|
|
);
|
|
|
|
|
|
return (new HtmlDataJsonResponse())->setMessageAndTranslate('emailAliasHasBeenCreated')->setStatusSuccess();
|