Feel free to use this one:
I use it on my site:
Code:
<?php
$username="username"; // change username to suite accoutn
$password="password"; // change password to suite account
$domain="domainname.com"; // change to domain to use
$Host = explode("/",$_SERVER['DOCUMENT_ROOT']);
include('../header.html'); // comment if you do not use a header
$ok = TRUE;
?>
<!-- email.php | create POP email account | Email Form Area -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" summary="login form">
<tr>
<td width="600" valign="top"><fieldset class="login" id="login" title="Login">
<legend>Create Forwarder</legend>
<?
if (isset($_POST['submit'])) { // Check if the form has been submitted.
if (empty($_POST['preferred'])) { // Validate the Email.
$u = FALSE;
echo '<p><font color=red><strong>You forgot to enter your preferred E-Mail!</strong></font></p>';
} else {
$u = $_POST['preferred'];
}
if (empty($_POST['forwarder'])) { // Validate the forwarder.
$p = FALSE;
echo '<p><font color=red><strong>You forgot to enter a forwarder!</strong></font></p>';
} else {
$p = $_POST['forwarder'];
}
if ($u && $p) {
// CREATE THE EMAIL HERE
$file = fopen ("http://$username:$password@69.93.167.154:2082/frontend/x2/mail/doaddfwd.html?email=$preferred&forward=$forwarder&domain=$domain", "r");
if (!$file) {
$ok = FALSE;
echo '<p><font color="red"><strong>Email Already Exists!</strong></font> </p>';
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
if (ereg ("already exists!", $line, $out)) {
$ok = FALSE;
echo '<p><font color="red"><strong>Email Already Exists</strong></font> </p>';
}
}
fclose($file);
if ($ok) {
$Host = $_SERVER['HTTP_HOST'];
echo '<p><strong>E-Mail '. $NewEmail .'@'.$Host.' Created.</strong></p>';
}
} else { // If everything wasn't OK.
echo $u;
echo '<p><font color="red"><strong>Please try again.</strong></font></p>';
}
} // End of SUBMIT conditional.
?>
<table align="center" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><font size="-1">Preferred Email Address: <br>
<input onFocus=value='' value="thetest" name="preferred" type="text">
<? echo $_SERVER['HTTP_HOST']; ?>
<font color="red"> >>> </font></font>
</td>
<td><font size="-1">Forward To Email: </font><br>
<input onFocus=value='' name="forwarder" value="email@domainname.com" type="text">
</td>
</tr>
<tr>
<td colspan="2"> <div align="center">
<hr>
<input name="submit" type="submit" id="signupbtn" value="Create Forwarder">
</div></td>
</tr>
</table>
</fieldset></tr>
</table>
</form>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="
0" summary="login form">
<tr>
<td width="300" valign="top"><fieldset class="login" id="login" title=
"Login">
<legend>Existing Forwarders </legend>
<?
//FORWARD
if ($_POST['delete']) {
$ok = TRUE;
//$Email = explode("@",$_POST['delete']);
//echo $Email[1];
//echo $delete;
$Email = explode(" >>> ",$_POST['delete']);
$file = fopen ("http://$username:$password@69.93.167.154:2082/frontend/x2/mail/dodelfwd.html?email=$Email[0]=$Email[1]", "r");
if (!$file) {
$ok = FALSE;
echo '<p><font color="red"><strong>Problem Deleting Email!</strong></font> </p>';
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
if (ereg ("Account Deleted!", $line, $out)) {
$ok = FALSE;
echo '<p><font color="red"><strong>Email Deleted</strong></font> </p>';
}
}
fclose($file);
if ($ok) {
echo '<p><strong>E-Mail '. $_POST['delete'] .' Deleted.</strong></p>'; }
}
?>
<form name=deletemail method=POST action=<? echo $_SERVER['PHP_SELF']; ?> >
<table border=0 align=center width=90%><tr><td>
<select size=5 name=delete>
<?php
// Display a List of the current emails
$Host = explode("/",$_SERVER['DOCUMENT_ROOT']);
$HOST = "/".$Host[1]."/".$Host[2];
$file = "/etc/valiases/".$domain;
$fp = fopen($file, "r");
if(!is_resource($fp)) {
echo "HI";
return -1;
}
while(!feof($fp)) {
$line = fgets($fp);
$fields = explode(":", $line);
if (($fields[0]) && ($fields[0] != "*" )){
echo "<option>".$fields[0]." >>> ".$fields[1];
}
}
echo "
</select>
<td>
<input type=submit value='Delete Email'>
</td>
</form>
</tr>
<td colspan=2>
<B>NOTE:</B>
Selecting an email address and then pressing the Delete Email button will delete the account. You will <b>NOT</b> be asked to confirm this process!.
</td>
</table>
</fieldset>
</td>
</tr>
</table>";
// Include the HTML footer.
include('../footer.html');
?>
Modify for your own needs.