WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : cPanel Email Accounts Creator
Categories : PHP, PHP Classes, Email, Form Processing, Web Services Click here to Update Your Picture
Md. Zakir Hossain
Date : Nov 21st 2006
Grade : 3 of 5 (graded 3 times)
Viewed : 12060
File : 4536.zip
Images : Image 1
Search : More code by Md. Zakir Hossain
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

Create e-mail addresses for cPanel accounts

This is a simple class that can be used create e-mail addresses for domains hosted using a cPanel account.

It extends a script originally made available in the zubrag.com Web site.

The class accesses a cPanel Web server and sends a command to create an e-mail account with a given address, password and quota.

The class retrieves and process the cPanel server response to determine whether the account creation was successful or it could not be created when the account already exists.


cpmail_class.php
<?php
/*
This class 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

Class Name: cpmail
Clas Title: cPanel Mail Accounts Creator
Purpose: Create cPanel email account without loggin in to cPanel.
Version: 1.0
Author: Md. Zakir Hossain (Raju)
URL: http://www.rajuru.xenexbd.com

Company: Xenex Web Solutions
URL: http://www.xenexbd.com

License: GPL
You can freely use, modify, distribute this script. But a credit line is appreciated.

Installation:
see example.php for details

*/

//definding main class
class cpmail{
 
//declare public variables
 
var $cpuser;    // cPanel username
 
var $cppass;        // cPanel password
 
var $cpdomain;      // cPanel domain or IP
 
var $cpskin;        // cPanel skin. Mostly x or x2.
 
  //defining constructor
 
function cpmail($cpuser,$cppass,$cpdomain,$cpskin='x'){
   
$this->cpuser=$cpuser;
   
$this->cppass=$cppass;
   
$this->cpdomain=$cpdomain;
   
$this->cpskin=$cpskin;
   
// See following URL to know how to determine your cPanel skin
    // http://www.zubrag.com/articles/determine-cpanel-skin.php
 
}

 
//now create email account, function takes three arguments
  /*
  $euser = email id
  $epass = email password
  $equota = mailbox allocated size
  */
 
function create($euser,$epass,$equota){
   
$path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/mail/doaddpop.html?quota=".$equota."&email=".$euser."&domain=".$this->cpdomain."&password=".$epass;
   
$f = fopen($path,"r");
    if (!
$f) {
      return(
'Cannot create email account. Possible reasons: "fopen" function not allowed on your server, PHP is running in SAFE mode');
    }

   
//check if the account exists
   
while (!feof ($f)) {
     
$line = fgets ($f, 1024);
      if (
ereg ("already exists!", $line, $out)) {
        return(
'Such email account already exists.');
      }
    }
   
fclose($f);
   
//return success message
   
return "Email account created.";
}
}

?>



//Usage Example
<?php
/*
This is the example script for cpmail class
*/

?>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>cPanel Email Creator</title>
</head>

<body>

<p><b><font size="5">Cpanel Email Creator</font></b></p>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

    <table border="0" width="52%" style="border-collapse: collapse">
        <tr>
            <td colspan="2">
            <p align="left"><b>Create Email Accounts</b></td>
        </tr>
        <tr>
            <td width="78">
            <p align="right">Username:</td>
            <td><input type="text" name="euser" size="20"></td>
        </tr>
        <tr>
            <td width="78">
            <p align="right">Password:</td>
            <td><input type="password" name="epass" size="20"></td>
        </tr>
        <tr>
            <td width="78"> </td>
            <td><input type="submit" value="Create New Account" name="create"></td>
        </tr>
    </table>
</form>
<p> </p>
<?php
if(isset($_POST['create'])){

//include class file
require_once('cpmail_class.php');

/*
  instanceiate class & pass three arguments cpanelusername, cpanelpassword,yourdomainname,cpanelskin
  See following URL to know how to determine your cPanel skin
  http://www.zubrag.com/articles/determine-cpanel-skin.php
  if you don't pass cpanelskin argument, default will be x
*/
$cpanel=new cpmail("rubdnet","secret2001","rubd.net","rvblue");

//call create function and you have to pass three arguments as follows:
//emailid, password, quota

echo $cpanel->create($_POST['euser'],$_POST['epass'],"20");
}
?>
</body>
</html>





PHP MIME Decoder. This class decodes Mime Encoded email message. Attachments are stored in a director. Works with Multipart/alternative, multipart/mixed etc. see http://p3mail.com for example.
Categories : PHP, PHP Classes, Email
FormChecker Package - validate any data via classes and patterns.
Categories : PHP, Form Processing, PHP Classes, Regexps
send_mail function to defeat Header Injection Hacking/Spamming
Categories : PHP, Email, Form Processing, Security
Validator - A PHP class that can can be used for validating Email IDs and Dates
Categories : PHP, PHP Classes, Data Validation, Email, Date Time
Three Cool Classes and One Trick
Categories : PHP, PHP Classes, Graphics, Email
Class that allows the PHP developer to establish connections with a POP3 mail server amd be able to list, retrieve and delete mail messages from a given mail box.
Categories : Network, Email, PHP, PHP Classes
Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects.
Categories : PHP, PHP Classes, XML, Web Services
Forms protected from XSS attacks (FOPAXSS)
Categories : PHP, PHP Classes, Form Processing, Security
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
cPanel Subdomains Creator - Create cPanel subdomains without logging into cPanel. Let your visitors create their own subdomains without your intervention. Moreover, it will inform if a subdomain is already exists.
Categories : PHP, Web Services, PHP Classes
send php mail with form data and attachment.
Categories : PHP, Email, Mail, Form Processing
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
EAvalidator - This class can be used to validate an e-mail address by checking its domain.
Categories : PHP, PHP Classes, Email, Regexps
Form Elements Class
Categories : PHP, PHP Classes, Form Processing
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services