Hello,
I tried using the script here to create email forwarders and it works fine. My problem is the script to delete email forwarders. I saw a script on the other forum but it doesn't work.
Here it is.
I don't know why it doesn't work. If anyone knows a working script. Let me know.
I tried using the script here to create email forwarders and it works fine. My problem is the script to delete email forwarders. I saw a script on the other forum but it doesn't work.
Here it is.
PHP:
<?php
###############################################################
# Delete Email Forwarder on cPanel
###############################################################
// cpanel user (the one you login to cpanel)
define('CPANELUSER','cpanel-username-here');
// cpanel password (the one you login to cpanel)
define('CPANELPASS','cpanel-password-here');
// your cpanel domain (localhost, or domain name)
define('CPANELDOMAIN','localhost');
// cPanel skin (usually "x")
// Check http://www.zubrag.com/articles/determine-cpanel-skin.php to know it for sure
define('CPANEL_SKIN','x');
////////////////////////////////////////////////////////////////
/////////////////////// END OF SETTINGS ////////////////////////
////////////////////////////////////////////////////////////////
function getVar($name, $def = '') {
if (isset($_REQUEST[$name]) && ($_REQUEST[$name] != ''))
return $_REQUEST[$name];
else
return $def;
}
$cpuser = CPANELUSER;
$cppass = CPANELPASS;
$cpdomain = CPANELDOMAIN;
$cpskin = CPANEL_SKIN;
$email=getVar('email');
$eforward=getVar('eforward');
if (empty($email) || empty($eforward)) {
echo "<h1>Delete Email Forwarder on cPanel</h1>";
echo "All fields are required.<br>
<form method='post'>
Email:<input name='email' value='$email'> (sample: john@mydomain.com)<br>
Forward: <input name='eforward' value='$eforward'> (sample: jimm@site2.com)<br>
<input type='submit' value='Delete forwarder' style='border:1px solid black'>
</form>";
die();
}
// Delete email forwarder
$f = @fopen
("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/dodelfwd.html?email=$email=$eforward",
"r");
if (!$f) {
die('Cannot delete forwarder.');
}
@fclose($f);
echo "Email Forwarder deleted: $email => $eforward";
?>
I don't know why it doesn't work. If anyone knows a working script. Let me know.