PHP code example of naif / php-cpanel-email

1. Go to this page and download the library: Download naif/php-cpanel-email library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

naif / php-cpanel-email example snippets


$cpanel = new cPanel()

$cpanel->getEmailAddresses()

Response:
array:5 [
  0 => Email {#227 ▼
    +user: "abc"
    +domain: "domain.com"
    +email: "[email protected]"
    +_diskused: 0
    +_diskquota: 0
    +humandiskused: "None"
    +humandiskquota: "None"
    +suspended_incoming: 0
    +suspended_login: 0
    +mtime: 1539715896
   }
 ]

$cpanel->create('username','password')

Response:
[
  "status" => "success"
  "message" => "Email address has been added successfully"
]

$cpanel->delete('email_address')

Response:
[
  "status" => "success"
  "message" => "Email address has been deleted successfully"
]

$cpanel->changePassword('username','password')

Response:
[
  "status" => "success"
  "message" => "Password has been changed successfully"
]

$cpanel->changeQuota('username',500)//quota as a number or 0 to set it as unlimited

Response:
[
  "status" => "success"
  "message" => "Email disk quota has been changed successfully"
]

composer