Hi
I'm using the script below to create a email forwarder
It basically create a forwarder for [email protected] to anything entered in the form name="forward"
example : [email protected] --> [email protected]
But can anyone help me with coding that first checks if the the [email protected] maybe already exists, if so then it break;
I'm using the script below to create a email forwarder
It basically create a forwarder for [email protected] to anything entered in the form name="forward"
example : [email protected] --> [email protected]
But can anyone help me with coding that first checks if the the [email protected] maybe already exists, if so then it break;
Code:
<?php
include("./xmlapi.php"); //XMLAPI cpanel client class
$ip = "localhost";
$account = "account_name";
$passwd ="password";
$port =2083;
$email_domain = 'domain.com';
function getVar($name, $def = '') {
if (isset($_REQUEST[$name]))
return $_REQUEST[$name];
else
return $def;
}
$dest_email = getVar('forward', '');
$email_user =getVar('new_email_forward', '');
if (!empty($email_user))
while(true) {
$xmlapi = new xmlapi($ip);
$xmlapi->set_port($port);
$xmlapi->password_auth($account, $passwd);
$call_f = array(domain=>$email_domain, email=>$email_user, fwdopt=>"fwd", fwdemail=>$dest_email);
$xmlapi->set_debug(0);
$result_forward = $xmlapi->api2_query($account, "Email", "addforward", $call_f);
?>
<html>
<head><title>Email Forward Creator</title></head>
<body>
<form name="frmEmail" method="post">
<table width="400" border="0">
<tr>
<td>Forwarder:</td>
<td><input name="forward" size="20" type="text" /></td>
</tr>
<tr>
<td>Forward to </td>
<td><input name="new_email_forward" size="20" type="text" /></td>
</tr>
<tr>
<td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Create Forward" /></td></tr>
</table>
</form>
</body>
</html>
<html><body></body></html>