@@ -18,6 +18,28 @@
|
||||
class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
{
|
||||
|
||||
/**
|
||||
* add a new email account for a given email-address either by id or emailaddr
|
||||
*
|
||||
* @param int $id
|
||||
* optional email-address-id of email-address to add the account for
|
||||
* @param string $emailaddr
|
||||
* optional email-address to add the account for
|
||||
* @param int $customerid
|
||||
* optional, admin-only, the customer-id
|
||||
* @param string $loginname
|
||||
* optional, admin-only, the loginname
|
||||
* @param string $email_password
|
||||
* password for the account
|
||||
* @param string $alternative_email
|
||||
* optional email address to send account information to, default is the account that is being created
|
||||
* @param int $email_quota
|
||||
* optional quota if enabled in MB, default 0
|
||||
*
|
||||
* @access admin, customer
|
||||
* @throws Exception
|
||||
* @return array
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->isAdmin() == false && Settings::IsInList('panel.customer_hide_options', 'email')) {
|
||||
@@ -181,6 +203,7 @@ class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
$mail_body = $this->getMailTemplate($customer, 'mails', 'pop_success_mailbody', $replace_arr, $this->lng['mails']['pop_success']['mailbody']);
|
||||
|
||||
$_mailerror = false;
|
||||
$mailerr_msg = "";
|
||||
try {
|
||||
$this->mailer()->SetFrom($admin['email'], getCorrectUserSalutation($admin));
|
||||
$this->mailer()->Subject = $mail_subject;
|
||||
@@ -197,7 +220,7 @@ class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
|
||||
if ($_mailerror) {
|
||||
$log->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
standard_error('errorsendingmail', $email_full, true);
|
||||
}
|
||||
|
||||
@@ -227,7 +250,7 @@ class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
}
|
||||
|
||||
if ($_mailerror) {
|
||||
$log->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
$this->logger()->logAction($this->isAdmin() ? ADM_ACTION : USR_ACTION, LOG_ERR, "[API] Error sending mail: " . $mailerr_msg);
|
||||
standard_error(array(
|
||||
'errorsendingmail'
|
||||
), $alternative_email, true);
|
||||
@@ -245,9 +268,13 @@ class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
throw new Exception("No more resources available", 406);
|
||||
}
|
||||
|
||||
/**
|
||||
* You cannot directly get an email account.
|
||||
* You need to call Emails.get()
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
throw new Exception('You cannot directly get an email forwarder. You need to call Emails.get()', 303);
|
||||
throw new Exception('You cannot directly get an email account. You need to call Emails.get()', 303);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,9 +283,11 @@ class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
* @param int $id
|
||||
* optional, the email-address-id
|
||||
* @param string $emailaddr
|
||||
* optional, the email-address to add the forwarder for
|
||||
* optional, the email-address to update
|
||||
* @param int $customerid
|
||||
* optional, required when called as admin/reseller
|
||||
* optional, admin-only, the customer-id
|
||||
* @param string $loginname
|
||||
* optional, admin-only, the loginname
|
||||
* @param int $email_quota
|
||||
* optional, update quota
|
||||
* @param string $email_password
|
||||
@@ -353,6 +382,10 @@ class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
return $this->response(200, "successfull", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* You cannot directly list email forwarders.
|
||||
* You need to call Emails.listing()
|
||||
*/
|
||||
public function listing()
|
||||
{
|
||||
throw new Exception('You cannot directly list email forwarders. You need to call Emails.listing()', 303);
|
||||
@@ -364,11 +397,13 @@ class EmailAccounts extends ApiCommand implements ResourceEntity
|
||||
* @param int $id
|
||||
* optional, the email-address-id
|
||||
* @param string $emailaddr
|
||||
* optional, the email-address to add the forwarder for
|
||||
* optional, the email-address to delete the account for
|
||||
* @param int $customerid
|
||||
* optional, admin-only, the customer-id
|
||||
* @param string $loginname
|
||||
* optional, admin-only, the loginname
|
||||
* @param bool $delete_userfiles
|
||||
* optional, default false
|
||||
* @param int $customerid
|
||||
* optional, required when called as admin/reseller
|
||||
*
|
||||
* @access admin,customer
|
||||
* @throws Exception
|
||||
|
||||
@@ -25,10 +25,12 @@ class EmailForwarders extends ApiCommand implements ResourceEntity
|
||||
* optional, the email-address-id
|
||||
* @param string $emailaddr
|
||||
* optional, the email-address to add the forwarder for
|
||||
* @param int $customerid
|
||||
* optional, admin-only, the customer-id
|
||||
* @param string $loginname
|
||||
* optional, admin-only, the loginname
|
||||
* @param string $destination
|
||||
* email-address to add as forwarder
|
||||
* @param int $customerid
|
||||
* optional, required when called as admin/reseller
|
||||
*
|
||||
* @access admin,customer
|
||||
* @throws Exception
|
||||
@@ -101,16 +103,28 @@ class EmailForwarders extends ApiCommand implements ResourceEntity
|
||||
throw new Exception("No more resources available", 406);
|
||||
}
|
||||
|
||||
/**
|
||||
* You cannot directly get an email forwarder.
|
||||
* You need to call Emails.get()
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
throw new Exception('You cannot directly get an email forwarder. You need to call Emails.get()', 303);
|
||||
}
|
||||
|
||||
/**
|
||||
* You cannot update an email forwarder.
|
||||
* You need to delete the entry and create a new one.
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
throw new Exception('You cannot update an email forwarder. You need to delete the entry and create a new one.', 303);
|
||||
}
|
||||
|
||||
/**
|
||||
* You cannot directly list email forwarders.
|
||||
* You need to call Emails.listing()
|
||||
*/
|
||||
public function listing()
|
||||
{
|
||||
throw new Exception('You cannot directly list email forwarders. You need to call Emails.listing()', 303);
|
||||
@@ -122,11 +136,13 @@ class EmailForwarders extends ApiCommand implements ResourceEntity
|
||||
* @param int $id
|
||||
* optional, the email-address-id
|
||||
* @param string $emailaddr
|
||||
* optional, the email-address to add the forwarder for
|
||||
* optional, the email-address to delete the forwarder from
|
||||
* @param int $customerid
|
||||
* optional, admin-only, the customer-id
|
||||
* @param string $loginname
|
||||
* optional, admin-only, the loginname
|
||||
* @param int $forwarderid
|
||||
* id of the forwarder to delete
|
||||
* @param int $customerid
|
||||
* optional, required when called as admin/reseller
|
||||
*
|
||||
* @access admin,customer
|
||||
* @throws Exception
|
||||
|
||||
@@ -28,7 +28,9 @@ class Emails extends ApiCommand implements ResourceEntity
|
||||
* @param boolean $iscatchall
|
||||
* optional, make this address a catchall address, default: no
|
||||
* @param int $customerid
|
||||
* optional, required when called as admin/reseller
|
||||
* optional, admin-only, the customer-id
|
||||
* @param string $loginname
|
||||
* optional, admin-only, the loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @throws Exception
|
||||
@@ -164,7 +166,7 @@ class Emails extends ApiCommand implements ResourceEntity
|
||||
$result_stmt = Database::prepare("SELECT v.`id`, v.`email`, v.`email_full`, v.`iscatchall`, v.`destination`, v.`customerid`, v.`popaccountid`, v.`domainid`, u.`quota`
|
||||
FROM `" . TABLE_MAIL_VIRTUAL . "` v
|
||||
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON v.`popaccountid` = u.`id`
|
||||
WHERE v.`customerid` IN (".implode(", ", $customer_ids).")
|
||||
WHERE v.`customerid` IN (" . implode(", ", $customer_ids) . ")
|
||||
AND (v.`id`= :idea OR (v.`email` = :idea OR v.`email_full` = :idea))
|
||||
");
|
||||
$result = Database::pexecute_first($result_stmt, $params, true, true);
|
||||
@@ -180,13 +182,15 @@ class Emails extends ApiCommand implements ResourceEntity
|
||||
* toggle catchall flag of given email address either by id or email-address
|
||||
*
|
||||
* @param int $id
|
||||
* optional, the customer-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 $iscatchall
|
||||
* optional
|
||||
* @param int $customerid
|
||||
* optional, required when called as admin/reseller
|
||||
*
|
||||
* @access admin, customer
|
||||
* @throws Exception
|
||||
@@ -257,9 +261,9 @@ class Emails extends ApiCommand implements ResourceEntity
|
||||
* 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
|
||||
*
|
||||
* @param int $customerid
|
||||
* optional, admin-only, select ftp-users of a specific customer by id
|
||||
* optional, admin-only, select email addresses of a specific customer by id
|
||||
* @param string $loginname
|
||||
* optional, admin-only, select ftp-users of a specific customer by loginname
|
||||
* optional, admin-only, select email addresses of a specific customer by loginname
|
||||
*
|
||||
* @access admin, customer
|
||||
* @throws Exception
|
||||
@@ -274,7 +278,7 @@ class Emails extends ApiCommand implements ResourceEntity
|
||||
FROM `" . TABLE_MAIL_VIRTUAL . "` m
|
||||
LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` d ON (m.`domainid` = d.`id`)
|
||||
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON (m.`popaccountid` = u.`id`)
|
||||
WHERE m.`customerid` IN (".implode(", ", $customer_ids).")
|
||||
WHERE m.`customerid` IN (" . implode(", ", $customer_ids) . ")
|
||||
");
|
||||
Database::pexecute($result_stmt, null, true, true);
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
@@ -291,13 +295,15 @@ class Emails extends ApiCommand implements ResourceEntity
|
||||
* delete an email address by either id or username
|
||||
*
|
||||
* @param int $id
|
||||
* optional, the customer-id
|
||||
* optional, the email-address-id
|
||||
* @param string $emailaddr
|
||||
* optional, the email-address
|
||||
* @param boolean $delete_userfiles
|
||||
* optional, delete email data from filesystem, default: no
|
||||
* @param int $customerid
|
||||
* optional, required when called as admin/reseller
|
||||
* optional, admin-only, the customer-id
|
||||
* @param string $loginname
|
||||
* optional, admin-only, the loginname
|
||||
* @param boolean $delete_userfiles
|
||||
* optional, delete email data from filesystem, default: 0 (false)
|
||||
*
|
||||
* @access admin, customer
|
||||
* @throws Exception
|
||||
|
||||
Reference in New Issue
Block a user