case "create_mail_alias":
//Requires $domain, $user, $mail_dst,
echo "Creating the mailbox alias $user@$domain pointing to $mail_dst\n";
//Alias verification
$result = $mysqli->query("SELECT `alias_id` FROM `domain_aliasses` WHERE `alias_name`='$domain'");
if ($result->num_rows>0) {
$row=$result->fetch_row();
$alias_id=$row[0];
$result->close();
} else {
echo "ERROR: You are trying to use a non-existant Alias domain\n";
exit(0);
}
//Domain verification
$result = $mysqli->query("SELECT `domain_id` FROM `domain_aliasses` WHERE `alias_name`='$domain'");
if ($result->num_rows>0) {
$row=$result->fetch_row();
$domain_id=$row[0];
$result->close();
} else {
echo "ERROR: You are trying to use a non-existant domain\n";
exit(0);
}
//Email verification
$result = $mysqli->query("SELECT `mail_addr` FROM `mail_users` WHERE `mail_addr`='$user@$domain'");
if ($result->num_rows !=0) {
echo "ERROR: You are trying to create an existant mail address\n";
exit(0);
}
//TODO, allow the quota to be set with a parameter
//Adding the alias
$sql = "INSERT INTO `mail_users` VALUES ('','" . $user . "','_no_" .
"','" . $mail_dst . "','" . $domain_id . "','alias_forward','" . $alias_id . "','toadd',0,'NULL',10485760,' " .
$user . "@" . $domain . "')";
//echo $sql . "\n";
//Adding the user
if (!$mysqli->query($sql)) {
printf("ERROR: %s\n", $mysqli->error);
exit(0);
}
break;