Show DevBest [PHP] [REL] cPanel Email Account Creator

Status
Not open for further replies.

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
I got pretty bored earlier and created a script from scratch that creates emails without you being in your cPanel.

I'm not sure if it works because when I uploaded the script and tried to test it, I had realised that my web host has added extra security which means that I have to be in my cPanel to do something like this.

The script looks like it should work. All you have to do is edit the $cPanel array values.

This script could be used in case you create a site where you allow people to have their own email account but with your domain on it - that is primarily why I coded this.

Below is the script if you are interested in it:

PHP:
<?php
/**
  * PHP cPanel Email Account Generator
  * Coded by Mark Eriksson
  * http://www.mark-eriksson.com
  * http://www.mark-eriksson.com/projects
  * http://www.facebook.com/9markeriksson4
  * http://www.twitter.com/iiM4RKx
  */

/**
  * Change the values of this array to your cPanel details.
  */
$cPanel             = array();
$cPanel["Username"] = "";
$cPanel["Password"] = "";
$cPanel["Domain"]   = ""; //No "http://" or "www."
$cPanel["Theme"]    = ""; //Usually found in your cPanel URL after "/frontend/".

/* End of settings */

/* Has the user filled out the form? */

if ( isset( $_GET['Email'] ) && isset( $_GET['Domain'] ) && isset( $_GET['Password'] ) && isset( $_GET['Quota'] ) )
{
$Email    = strip_tags( $_GET['Email'] );
$Domain   = strip_tags( $_GET['Domain'] );
$Password = strip_tags( $_GET['Password'] );
$Quota    = ( !empty( $_GET['Quota'] ) && is_numeric( $_GET['Quota'] ) ) ? strip_tags( $_GET['Quota'] ) : 20; //value is in MB. 0 for unlimited

if ( empty( $Email ) || empty( $Password ) || empty( $Quota ) )
{
die( "All fields are required.<br /><br /><a href=\"" . $_SERVER['PHP_SELF'] . "\">Try again.</a>" );
}
else
{
$CreateEmail = @fopen( "http://" . $cPanel["Username"] . ":" . $cPanel["Password"] . "@" . $cPanel["Domain"] . ":2082/frontend/" . $cPanel["Theme"] . "/mail/doaddpop.html?email=" . $Email . "&domain=" . $Domain . "&password=" . $Password . "&quota=" . $Quota, "r" );
if ( !$CreateEmail )
{
die( "Could not create email account - your PHP may be running in safe mode because <code>fopen</code> appears to not be working properly." );
break;
}
else
{
while( !feof( $CreateEmail ) )
{
$Line = fgets( $CreateEmail, 1024 );
if ( ereg( "already exists!", $Line, $out ) )
{
die( "Sorry, the account <strong>" . $Email . "@" . $Domain . "</strong> already exists on this web server.<br /><br /><a href=\"" . $_SERVER['PHP_SELF'] . "\">Try again.</a>" );
break;
}
else
{
echo "The email account <strong>" . $Email . "@" . $Domain . "</strong> has been successfully created!<br /><br /><a href=\"" . $_SERVER['PHP_SELF'] . "\">Create another.</a>";
}
break;
}
}
@fclose( $CreateEmail );
echo "http://" . $cPanel["Username"] . ":" . $cPanel["Password"] . "@" . $cPanel["Domain"] . ":2082/frontend/" . $cPanel["Theme"] . "/mail/doaddpop.html?email=" . $Email . "&domain=" . $Domain . "&password=" . $Password . "&quota=" . $Quota;
}
}
else
{
$PasswordType   = ( isset( $_GET['hide_password'] ) || $_GET['hide_password'] == "1" ) ? "password" : "text";
$PasswordString = ( isset( $_GET['hide_password'] ) ) ? "<a href=\"" . $_SERVER['PHP_SELF'] . "\">Show password</a>" : "<a href=\"?hide_password\">Hide password</a>";
echo "<form method=\"get\" action=\"" . $_SERVER['PHP_SELF'] . "\">
<table>
<tbody>
<tr>
<td><label>Email Account:</label></td>
<td><input type=\"text\" name=\"Email\" id=\"Email\" size=\"15\" style=\"text-align: right;\" />@<input type=\"text\" name=\"Domain\" id=\"Domain\" size=\"25\" value=\"" . $_SERVER['SERVER_NAME'] . "\" /></td>
<td></td>
</tr>
<tr>
<td><label for=\"Password\">Password:</label></td>
<td><input type=\"" . $PasswordType . "\" name=\"Password\" id=\"Password\" size=\"49\" /></td>
<td>" . $PasswordString . "</td>
</tr>
<tr>
<td><label for=\"Quota\">Quota:</label></td>
<td><input type=\"text\" name=\"Quota\" id=\"Quota\" size=\"5\" />mb</td>
<td></td>
</tr>
<tr>
<td></td>
<td><input type=\"submit\" name=\"Create\" id=\"Create\" value=\"Create\" /></td>
<td></td>
</tr>
</tbody>
</table>
</form>";
}
?>

Enjoy,
- m0nsta.

For a better look at the code:
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,198
3,914
Holly shit, nice one Mark, nice to see you contributing :p.
 
Status
Not open for further replies.

Users who are viewing this thread

Top