1 (edited by pyuvaraj 2021-08-11 01:38:36)

Topic: How to disable user email account using API.

Hi,
As per my review on iRedAdmin Pro API docs,iRedAdmin don't have the option to disable user email account.
but it has the option to disable user email account in iRedAdmin console.

Please help me out how to disable a user email account via API.

Sample Code API for Deleting user email account:

public function delete_user ($API_HOST, $MAIL, $DAYS = NULL) {
      $curl = curl_init();
      if (!is_null($DAYS) && is_numeric($DAYS)) {
        curl_setopt($curl, CURLOPT_URL, "$API_HOST/user/$MAIL/keep_mailbox_days/$DAYS");
      } else {
        curl_setopt($curl, CURLOPT_URL, "$API_HOST/user/$MAIL");
      }
      if (!defined('COOKIE_FILE')) { define("COOKIE_FILE", dirname(__FILE__) . "/cookies.txt"); }
      curl_setopt_array($curl, array(
        CURLOPT_CUSTOMREQUEST => "DELETE",       
        CURLOPT_SSL_VERIFYHOST => false,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_COOKIEJAR => COOKIE_FILE,
        CURLOPT_COOKIEFILE => COOKIE_FILE
      ));

      $response = curl_exec($curl);
      $err = curl_error($curl);
      curl_close($curl);
      $iredmail_response = json_decode($response);
      return $iredmail_response;
  }

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: How to disable user email account using API.

If you're running an iRedAdmin-Pro license, please check our API document:
https://docs.iredmail.org/iredadmin-pro … l.api.html

PUT /api/user/<mail>
Parameter accountStatus=disabled