#!/usr/local/bin/perl
# delete_queue.cgi
# Delete a mail messsage from the queue

require './qmail-lib.pl';
&ReadParse();

-r $in{'file'} || &error($text{'delete_egone'});
$in{'file'} =~ /(\d+)\/(\d+)$/;
$id = "$1/$2";
($pid) = &find_byname("qmail-send");
if ($pid && kill(0, $pid)) {
	# Need to stop qmail first
	&kill_logged(TERM, $pid);
	}

unlink("$qmail_mess_dir/$id");
unlink("$qmail_info_dir/$id");
unlink("$qmail_remote_dir/$id");
unlink("$qmail_local_dir/$id");

if ($pid) {
	# Need to re-start qmail
	&system_logged("$qmail_start_cmd >/dev/null 2>&1 </dev/null &");
	}

&redirect("list_queue.cgi");

