cPanel: Class for creating email account and mail forwarder

cpanel logo cPanel: Class for creating email account and mail forwarderThis class can be used to create email account and mail forwarders using PHP, without logging to cPanel. It is an extension of script made by www.zubrag.com. You can access the original link from here http://www.zubrag.com/scripts/cpanel-create-email-account.php. And it is also a modified version of the class “cpmail” which was coded by Md. Zakir Hossain (Raju), http://www.rajuru.xenexbd.com. How to configure:

  1. Download the zipped file.
  2. Unzip the file. This file contains the class file and an example file.
  3. Open the class file and change these variables –
    • $currentTheme – Your cPanel theme
    • $userName – Your cPanel user name
    • $password – Your cPanel password
    • $domain – Your cPanel domain
    • $cPanelPort – Your cPanel port [optional]
  4. Include the class in the file where you want to use it.

Example:

// include the class file
include('class.cpmailmanager.php');
 
// create an instanse of the class
$cp = new CPMailManager();
 
// create an email account
$cp->createEmail('sadat', 'sadat123', 10);
 
if($cp->status) //account created successfully
{
     echo 'Mail created successfully';
}
else
{
     echo $cp->message;
}
 
// create mail forwarder
$cp->createForwarder('sadat', 'msh@example.com');
echo '' . $cp->message;
 
// delete mail forwarder
$cp->deleteForwarder('sadat', 'msh@example.com');
echo '' . $cp->message;
 
// delete email account
$cp->deleteEmail('sadat');
echo '' . $cp->message;

download cPanel: Class for creating email account and mail forwarder

share save 120 16 cPanel: Class for creating email account and mail forwarder