Added flag for flushing quarantined mail
authorJamie Cameron <jcameron@webmin.com>
Tue, 12 May 2009 22:02:47 +0000 (22:02 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 12 May 2009 22:02:47 +0000 (22:02 +0000)
sendmail/CHANGELOG
sendmail/del_mailqs.cgi
sendmail/list_mailq.cgi
sendmail/sendmail-lib.pl

index 5c39976..65e5688 100644 (file)
@@ -42,3 +42,5 @@ Added a Module Config option to control if the user is prompted for confirmation
 A custom command to rebuild all maps can be specified on the Module Config page, to be used instead of makemap or newaliases.
 ---- Changes since 1.450 ----
 Changed the mail queue date format to yyyy/mm/dd, for easier sorting.
+---- Changes since 1.480 ----
+When flushing selected queued quarantined messages, the -qQ flag is added so that it actually works.
index 644cffd..7f3e95c 100755 (executable)
@@ -13,20 +13,32 @@ if ($in{'flush'}) {
        $access{'flushq'} || &error($text{'flushq_ecannot'});
        &ui_print_unbuffered_header(undef, $text{'flushq_title'}, "");
 
-       $cmd = "$config{'sendmail_path'} -v -C$config{'sendmail_cf'}";
-       foreach $file (@files) {
-               $file =~ s/^.*\///;
-               $cmd .= " -qI$file";
-               }
-       if ($config{'mailq_order'}) {
-               $cmd .= " -O QueueSortOrder=$config{'mailq_order'}";
+       # Split into quarantined and non-quarantined messages
+       local @mails = map { &mail_from_queue($_) } @files;
+       local @quar = grep { $_->{'quar'} } @mails;
+       local @nonquar = grep { !$_->{'quar'} } @mails;
+
+       foreach $ml (\@quar, \@nonquar) {
+               next if (!@$ml);
+               @files = map { $_->{'file'} } @$ml;
+               $cmd = "$config{'sendmail_path'} -v -C$config{'sendmail_cf'}";
+               if ($ml->[0]->{'quar'}) {
+                       $cmd .= " -qQ";
+                       }
+               foreach $file (@files) {
+                       $file =~ s/^.*\///;
+                       $cmd .= " -qI$file";
+                       }
+               if ($config{'mailq_order'}) {
+                       $cmd .= " -O QueueSortOrder=$config{'mailq_order'}";
+                       }
+               print &text('flushq_desc2', scalar(@files)),"\n";
+               print "<pre>";
+               &foreign_require("proc", "proc-lib.pl");
+               &foreign_call("proc", "safe_process_exec_logged", $cmd, 0, 0,
+                             STDOUT, undef, 1);
+               print "</pre>\n";
                }
-       print &text('flushq_desc2', scalar(@files)),"\n";
-       print "<pre>";
-       &foreign_require("proc", "proc-lib.pl");
-       &foreign_call("proc", "safe_process_exec_logged", $cmd, 0, 0,
-                     STDOUT, undef, 1);
-       print "</pre>\n";
        &webmin_log("flushq", undef, scalar(@files));
        }
 else {
index 284cb8d..f9d05e7 100755 (executable)
@@ -82,7 +82,7 @@ if (@qfiles) {
                }
 
        # Show the queued mails
-       &mailq_table([ @qfiles[$s .. $e] ], \%qmails);
+       $quarcount = &mailq_table([ @qfiles[$s .. $e] ], \%qmails);
 
        # Show queue search form
        print "<form action=mailq_search.cgi>\n";
index c047f02..161e9e1 100644 (file)
@@ -535,10 +535,11 @@ else {
 }
 
 # mailq_table(&qfiles)
-# Print a table showing queued emails
+# Print a table showing queued emails. Returns the number quarantined.
 sub mailq_table
 {
 local ($qfiles, $qmails) = @_;
+local $quarcount;
 
 # Show buttons to flush and delete
 print "<form action=del_mailqs.cgi method=post>\n";
@@ -638,6 +639,7 @@ if ($access{'mailq'} == 2) {
        print "<p>\n";
        }
 print "</form>\n";
+return $quarcount;
 }
 
 # is_table_comment(line, [force-prefix])