array ("request","integer",""),
		 "pass" => array ("request","string",""),
		 "passconf" => array("request","string",""),
		 "quotamb" => array("request","integer",0),
		 "enabled" => array("request","boolean",true),
		 "islocal" => array("request","boolean",true),
		 "recipients" => array("request","string",""),
		 );
getFields($fields);
$isedit=true; // if we go back to edit, it will know ;)
$error="";
// We check that email first ... so that we can compare its status with our ...
if (!$res=$mail->get_details($mail_id)) {
  $error=$err->errstr();
  include("main.php");
  exit();
} else {
  
  
  /*
   * checking the password
   */
  if(isset($pass) && $pass != ""){
    if($pass != $passconf){
      $error = _("Passwords do not match");
      include ("mail_edit.php");
      exit();
    } else {
      if (!$mail->set_passwd($mail_id,$pass)) { /* SET THE PASSWORD */
	$error=$err->errstr();
	include ("mail_edit.php");
	exit();
      } else {
	$error.=$err->errstr()."
";
      }
    }	
  }
  /* 
   * now the enable/disable status
   */
  if ($res["enabled"] && !$enabled) {
    if (!$mail->disable($mail_id)) { /* DISABLE */
      $error=$err->errstr();
      include ("mail_edit.php");
      exit();
    } else {
      $error.=$err->errstr()."
";
    }
  }
  if (!$res["enabled"] && $enabled) {
    if (!$mail->enable($mail_id)) { /* ENABLE */
      $error=$err->errstr();
      include ("mail_edit.php");
      exit();
    } else {
      $error.=$err->errstr()."
";
    }
  }
  /* 
   * now the islocal + quota + recipients 
   */
  if (!$mail->set_details($mail_id,$islocal,$quotamb,$recipients)) { /* SET OTHERS */
    $error=$err->errstr();
    include ("mail_edit.php");
    exit();
  } else {
    $error.=$err->errstr()."
";
  }
  /* 
   * Other elements by hooks
   */
  $rh=$hooks->invoke("mail_edit_post",array($mail_id));
  if (in_array(false,$res,true)) {
    include ("mail_edit.php");
    exit();
  } else {
    foreach($rh as $h) if ($h) $error.=$h."
";
  }
} 
if (!$error || !trim($error,"
")) $error=_("Your email has been edited successfully");
$_REQUEST["domain_id"]=$dom->get_domain_byname($res["domain"]);
include("mail_list.php");