<?php


// cPanel info
$cpuser = &#39;userhere&#39;; // cPanel username
$cppass = &#39;passwordhere&#39;; // cPanel password
$cpdomain = &#39;mysite.com&#39;; // cPanel domain or IP
$cpskin = &#39;x&#39;; // cPanel skin. Mostly x or x2.
// See following URL to know how to determine your cPanel skin

// Default email info for new email accounts
// These will only be used if not passed via URL
$epass = &#39;hispassword&#39;; // email password
$edomain = &#39;mysite.com&#39;; // email domain (usually same as cPanel domain above)
$equota = 20; // amount of space in megabytes


function getVar($name, $def = &#39;&#39 {
if (isset($_REQUEST[$name]))
return $_REQUEST[$name];
else
return $def;
}

// check if overrides passed
$euser = getVar(&#39;user&#39;, &#39;&#39;
$epass = getVar(&#39;pass&#39;, $epass);
$edomain = getVar(&#39;domain&#39;, $edomain);
$equota = getVar(&#39;quota&#39;, $equota);

$msg = &#39;&#39;;

if (!empty($euser)) {

// Create email account
$f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&passwor d=$epass&quota=$equota", "r");
if (!$f) {
$msg = &#39;Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode&#39;;
}
else {
$msg = "<h2>Email account {$euser}@{$edomain} created.</h2>";

// Check result
while (!feof ($f)) {
$line = fgets ($f, 1024);
if (ereg ("already exists", $line, $out)) {
$msg = "<h2>Email account {$euser}@{$edomain} already exists.</h2>";
break;
}
}
fclose($f);
}

}

?>
<html>
<head><title>cPanel Email Account Creator</title></head>
<body>
<?php echo $msg; ?>
<h1>cPanel Email Account Creator</h1>
<form name="frmEmail" method="post">
<table width="400" border="0">
<tr><td>Username:</td><td><input name="user" size="20" value="<?php echo htmlentities($euser); ?>" /></td></tr>
<tr><td>Password:</td><td><input name="pass" size="20" type="password" /></td></tr>
<tr><td colspan="2" align="center"><input name="submit" type="submit" value="Create Email Account" /></td></tr>
</table>
</form>
</body>
</html>