PHP Classes

PHP cPanel API Email Manager: Create and manage email accounts using cPanel API

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 57%Total: 350 All time: 6,996 This week: 39Up
Version License PHP version Categories
cpmm 1.0Free To Use But R...5Email, PHP 5, Web services, Hosting
Description 

Author

This class can create and manage email accounts using the cPanel API.

It can send HTTP requests to the cPanel API of a hosting account to perform several types of operations to manage email accounts.

Currently it can check if a given email account exists, create a new email account, get the list of created email accounts, change the password of an email account and delete an email account.

Picture of Rob
Name: Rob <contact>
Classes: 3 packages by
Country: United States United States
Age: 35
All time rank: 2638363 in United States United States
Week rank: 170 Up21 in United States United States Up

Example

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>cPanelMailManager Example</title>
        <style>
            .wrapper{width:70%; display:block; margin: 0 auto; font-family:monospace;}
        </style>
    </head>
    <body>
        <div class="wrapper">
            <?php

           
// include the library
           
require("class.cpmm.php");

           
// cPanel domain or IP
           
$host = "mywebsite.com";

           
// cPanel Username
           
$user = "cPanel_Username";

           
// cPanel Password
           
$pass = "cPanel_Password";
           
            if(
$host == "mywebsite.com"){
                echo
"Put your cPanel credentials in and remove line ".__LINE__." from the example script before running."; exit;
            }

           
// initialize the class
           
$cpmm = new cPanelMailManager($user, $pass, $host);

           
// Create a new email address
           
$email = "newemail@mywebsite.com";
           
$password = "mybadpassword";
           
$result = $cpmm->createEmail($email,$password);
            echo
"Email ($email) ".($result ? "successfully" : "not")." created.<br />";

           
// Check if an email exists
           
$email = "newemail@mywebsite.com";
           
$result = $cpmm->emailExists($email);
            echo
"Email ($email) ".($result ? "does" : "does not")." exist.<br />";

           
// Change an email password
           
$email = "newemail@mywebsite.com";
           
$newPassword = "mybetterpassword";
           
$result = $cpmm->changePW($email,$newPassword);
            echo (
$result ? "Changed" : "Could not change")." password for email $email.<br />";

           
// Delete an email account
           
$email = "newemail@mywebsite.com";
           
$result = $cpmm->deleteEmail($email);
            echo (
$result ? "Deleted" : "Could not delete")." email account $email.<br />";

           
// List email accounts
           
$pageSize = 15;
           
$pageNo = 1;
           
$result = $cpmm->listEmails($pageSize, $pageNo);
            echo
"<pre>";
           
var_dump($result);

           
?>
</div>
    </body>
</html>


  Files folder image Files (2)  
File Role Description
Plain text file class.cpmm.php Class Base Library for cPanel email APIs
Plain text file example.php Example Examples of the cPanelMailManager Library

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:350
This week:0
All time:6,996
This week:39Up
 User Ratings  
 
 All time
Utility:83%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:57%StarStarStar
Rank:1667