function QueueDirectoryRemount()
{
    $unix = new unix();
    if (QueueDirectoryIsMounted()) {
        $umount = $unix->find_program("umount");
        $cmd = "{$umount} /var/spool/artica-advmem";
        for ($i = 0; $i < 50; $i++) {
            shell_exec("{$cmd}");
            if (!QueueDirectoryIsMounted()) {
                break;
            }
        }
        if (QueueDirectoryIsMounted()) {
            echo "Failed to umount `{$cmd}`\n";
            return;
        }
    }
    QueueDirectoryConfig();
}
define(RM_STATE_READING_FROM, 2);
define(RM_STATE_READING_SUBJECT, 3);
define(RM_STATE_READING_SENDER, 4);
define(RM_STATE_READING_BODY, 5);
if (preg_match("#--verbose#", implode(" ", $argv))) {
    $GLOBALS["VERBOSE"] = true;
    echo "verbose=true;\n";
}
$GLOBALS["VERBOSE"] = true;
if ($GLOBALS["VERBOSE"]) {
    events("receive: " . implode(" ", $argv), "main", __LINE__);
}
$options = parse_args(array('s', 'r', 'c', 'h', 'u', 'i', 'z'), $_SERVER['argv']);
//getopt("s:r:c:h:u:");
$Masterdirectory = "/var/spool/artica-adv";
if (QueueDirectoryIsMounted()) {
    $Masterdirectory = "/var/spool/artica-advmem";
}
if (!array_key_exists('r', $options) || !array_key_exists('s', $options)) {
    fwrite(STDOUT, "Usage is {$argv['0']} -s sender@domain -r recip@domain\n");
    exit(EX_TEMPFAIL);
}
$GLOBALS_ARRAY["sender"] = strtolower($options['s']);
$GLOBALS_ARRAY["recipients"] = $options['r'];
$GLOBALS_ARRAY["original_recipient"] = $options['r'];
$GLOBALS_ARRAY["POSTFIX_INSTANCE"] = $options['i'];
$client_address = $options['c'];
$smtp_final_sender = strtolower($options['h']);
$sasl_username = strtolower($options['u']);
events("starting up, [{$GLOBALS_ARRAY["POSTFIX_INSTANCE"]}] sender={$GLOBALS_ARRAY["sender"]}, recipient={$GLOBALS_ARRAY["recipients"]}, client_address={$client_address}", "main", __LINE__);
$tb = explode("@", $GLOBALS_ARRAY["recipients"]);