|
|
|
|
@@ -54,6 +54,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
|
$iscatchall = $this->getBoolParam('iscatchall', true, 0);
|
|
|
|
|
$disablegreylist = $this->getBoolParam('disablegreylist', true, 0);
|
|
|
|
|
|
|
|
|
|
// validation
|
|
|
|
|
if (substr($domain, 0, 4) != 'xn--') {
|
|
|
|
|
@@ -72,6 +73,9 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|
|
|
|
if (Settings::Get('catchall.catchall_enabled') != '1') {
|
|
|
|
|
$iscatchall = 0;
|
|
|
|
|
}
|
|
|
|
|
if (Settings::Get('mail.greylist_enabled') != '1') {
|
|
|
|
|
$disablegreylist = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check for catchall-flag
|
|
|
|
|
if ($iscatchall) {
|
|
|
|
|
@@ -120,6 +124,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|
|
|
|
`email` = :email,
|
|
|
|
|
`email_full` = :email_full,
|
|
|
|
|
`iscatchall` = :iscatchall,
|
|
|
|
|
`disablegreylist` = :disablegreylist,
|
|
|
|
|
`domainid` = :domainid
|
|
|
|
|
");
|
|
|
|
|
$params = array(
|
|
|
|
|
@@ -127,6 +132,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|
|
|
|
"email" => $email,
|
|
|
|
|
"email_full" => $email_full,
|
|
|
|
|
"iscatchall" => $iscatchall,
|
|
|
|
|
"disablegreylist" => $disablegreylist,
|
|
|
|
|
"domainid" => $domain_check['id']
|
|
|
|
|
);
|
|
|
|
|
Database::pexecute($stmt, $params, true, true);
|
|
|
|
|
@@ -166,7 +172,7 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|
|
|
|
$customer_ids = $this->getAllowedCustomerIds('email');
|
|
|
|
|
$params['idea'] = ($id <= 0 ? $emailaddr : $id);
|
|
|
|
|
|
|
|
|
|
$result_stmt = Database::prepare("SELECT v.`id`, v.`email`, v.`email_full`, v.`iscatchall`, v.`destination`, v.`customerid`, v.`popaccountid`, v.`domainid`, u.`quota`
|
|
|
|
|
$result_stmt = Database::prepare("SELECT v.`id`, v.`email`, v.`email_full`, v.`iscatchall`, v.`destination`, v.`customerid`, v.`popaccountid`, v.`domainid`, u.`quota`, v.`disablegreylist`
|
|
|
|
|
FROM `" . TABLE_MAIL_VIRTUAL . "` v
|
|
|
|
|
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON v.`popaccountid` = u.`id`
|
|
|
|
|
WHERE v.`customerid` IN (" . implode(", ", $customer_ids) . ")
|
|
|
|
|
@@ -226,7 +232,6 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
|
$iscatchall = $this->getBoolParam('iscatchall', true, $result['iscatchall']);
|
|
|
|
|
|
|
|
|
|
// get needed customer info to reduce the email-address-counter by one
|
|
|
|
|
$customer = $this->getCustomerData();
|
|
|
|
|
|
|
|
|
|
@@ -272,7 +277,97 @@ class Emails extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt
|
|
|
|
|
));
|
|
|
|
|
return $this->response(200, "successfull", $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* toggle greylist flag of given email address either by id or email-address
|
|
|
|
|
*
|
|
|
|
|
* @param int $id
|
|
|
|
|
* optional, the email-address-id
|
|
|
|
|
* @param string $emailaddr
|
|
|
|
|
* optional, the email-address
|
|
|
|
|
* @param int $customerid
|
|
|
|
|
* optional, admin-only, the customer-id
|
|
|
|
|
* @param string $loginname
|
|
|
|
|
* optional, admin-only, the loginname
|
|
|
|
|
* @param boolean $disablegreylist
|
|
|
|
|
* optional
|
|
|
|
|
*
|
|
|
|
|
* @access admin, customer
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
* @return string json-encoded array
|
|
|
|
|
*/
|
|
|
|
|
public function update_greylist()
|
|
|
|
|
{
|
|
|
|
|
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'email')) {
|
|
|
|
|
throw new \Exception("You cannot access this resource", 405);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if enabling catchall is not allowed by settings, we do not need
|
|
|
|
|
// to run update()
|
|
|
|
|
if (Settings::Get('mail.greylist_enabled') != '1') {
|
|
|
|
|
\Froxlor\UI\Response::standard_error(array(
|
|
|
|
|
'operationnotpermitted',
|
|
|
|
|
'featureisdisabled'
|
|
|
|
|
), 'catchall', true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$id = $this->getParam('id', true, 0);
|
|
|
|
|
$ea_optional = ($id <= 0 ? false : true);
|
|
|
|
|
$emailaddr = $this->getParam('emailaddr', $ea_optional, '');
|
|
|
|
|
|
|
|
|
|
$result = $this->apiCall('Emails.get', array(
|
|
|
|
|
'id' => $id,
|
|
|
|
|
'emailaddr' => $emailaddr
|
|
|
|
|
));
|
|
|
|
|
$id = $result['id'];
|
|
|
|
|
|
|
|
|
|
// parameters
|
|
|
|
|
$disablegreylist = $this->getBoolParam('disablegreylist', true, $result['disablegreylist']);
|
|
|
|
|
// get needed customer info to reduce the email-address-counter by one
|
|
|
|
|
$customer = $this->getCustomerData();
|
|
|
|
|
|
|
|
|
|
// check for catchall-flag
|
|
|
|
|
if ($disablegreylist) {
|
|
|
|
|
$disablegreylist = '1';
|
|
|
|
|
$email_parts = explode('@', $result['email_full']);
|
|
|
|
|
$email = '@' . $email_parts[1];
|
|
|
|
|
// catchall check
|
|
|
|
|
$stmt = Database::prepare("
|
|
|
|
|
SELECT `email_full` FROM `" . TABLE_MAIL_VIRTUAL . "`
|
|
|
|
|
WHERE `email` = :email AND `customerid` = :cid AND `disablegreylist` = '1'
|
|
|
|
|
");
|
|
|
|
|
$params = array(
|
|
|
|
|
"email" => $email,
|
|
|
|
|
"cid" => $customer['customerid']
|
|
|
|
|
);
|
|
|
|
|
$email_check = Database::pexecute_first($stmt, $params, true, true);
|
|
|
|
|
if ($email_check) {
|
|
|
|
|
\Froxlor\UI\Response::standard_error('youhavealreadyacatchallforthisdomain', '', true);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$disablegreylist = '0';
|
|
|
|
|
$email = $result['email_full'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$stmt = Database::prepare("
|
|
|
|
|
UPDATE `" . TABLE_MAIL_VIRTUAL . "`
|
|
|
|
|
SET `email` = :email , `disablegreylist` = :disablegreylist
|
|
|
|
|
WHERE `customerid`= :cid AND `id`= :id
|
|
|
|
|
");
|
|
|
|
|
$params = array(
|
|
|
|
|
"email" => $email,
|
|
|
|
|
"disablegreylist" => $disablegreylist,
|
|
|
|
|
"cid" => $customer['customerid'],
|
|
|
|
|
"id" => $id
|
|
|
|
|
);
|
|
|
|
|
Database::pexecute($stmt, $params, true, true);
|
|
|
|
|
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] toggled greylist-flag for email address '" . $result['email_full'] . "'");
|
|
|
|
|
|
|
|
|
|
$result = $this->apiCall('Emails.get', array(
|
|
|
|
|
'emailaddr' => $result['email_full']
|
|
|
|
|
));
|
|
|
|
|
return $this->response(200, "successfull", $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* list all email addresses, if called from an admin, list all email addresses of all customers you are allowed to view, or specify id or loginname for one specific customer
|
|
|
|
|
*
|
|
|
|
|
|