PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 338 All time: 7,076 This week: 95Up
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: 2655365 in United States United States
Week rank: 524 Up55 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  
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

 Version Control Unique User Downloads Download Rankings  
 0%
Total:338
This week:0
All time:7,076
This week:95Up