columns=Columns for aliases and other tables,1,2-2,1-1
show_cmts=Show descriptions in tables?,1,1-Yes,0-No
prefix_cmts=Prefix all description comments with <tt>Webmin</tt>?,1,1-Yes,0-No
-mailq_sort=Sort mail queue by,1,0-Queue ID,1-From address,2-To address,4-Status,5-Size
+mailq_sort=Sort mail queue by,1,0-Queue ID,1-From address,2-To address,4-Status,5-Size,6-Sent date
mailq_count=Show size of mail queue on main page?,1,0-Yes,1-No
check_config=Test config file after change?,1,1-Yes,0-No
index_check=Check Postfix configuration on main page?,1,1-Yes,0-No
# gives a new number of mapping
sub init_new_mapping
{
-$maps = &get_maps($_[0]);
-
+my $maps = &get_maps($_[0]);
my $max_number = 0;
-
-foreach $trans (@{$maps})
-{
-if ($trans->{'number'} > $max_number) { $max_number = $trans->{'number'}; }
-}
-
+foreach $trans (@{$maps}) {
+ if ($trans->{'number'} > $max_number) {
+ $max_number = $trans->{'number'};
+ }
+ }
return $max_number+1;
}
{
local @s = &postfix_mail_system();
if ($s[0] == 0) {
-return "$s[1]/$_[0]";
-}
+ return "$s[1]/$_[0]";
+ }
elsif (@_ > 1) {
-return "$_[7]/$s[1]";
-}
+ return "$_[7]/$s[1]";
+ }
else {
-local @u = getpwnam($_[0]);
-return "$u[7]/$s[1]";
-}
+ local @u = getpwnam($_[0]);
+ return "$u[7]/$s[1]";
+ }
}
# postfix_mail_system()
sub postfix_mail_system
{
if (!defined(@mail_system_cache)) {
-local $home_mailbox = &get_current_value("home_mailbox");
-if ($home_mailbox) {
-@mail_system_cache = $home_mailbox =~ /^(.*)\/$/ ?
- (2, $1) : (1, $home_mailbox);
-}
-else {
-local $mail_spool_directory =
- &get_current_value("mail_spool_directory");
-@mail_system_cache = (0, $mail_spool_directory);
-}
-}
+ local $home_mailbox = &get_current_value("home_mailbox");
+ if ($home_mailbox) {
+ @mail_system_cache = $home_mailbox =~ /^(.*)\/$/ ?
+ (2, $1) : (1, $home_mailbox);
+ }
+ else {
+ local $mail_spool_directory =
+ &get_current_value("mail_spool_directory");
+ @mail_system_cache = (0, $mail_spool_directory);
+ }
+ }
return wantarray ? @mail_system_cache : $mail_system_cache[0];
}
local @qfiles;
&open_execute_command(MAILQ, $config{'mailq_cmd'}, 1, 1);
while(<MAILQ>) {
-next if (/^(\S+)\s+is\s+empty/i || /^\s+Total\s+requests:/i);
-if (/^([^\s\*\!]+)[\*\!]?\s*(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+)\s+(.*)/) {
-push(@qfiles, { 'id' => $1,
- 'size' => $2,
- 'date' => $3,
- 'from' => $4 });
-}
-elsif (/\((.*)\)/ && @qfiles) {
-$qfiles[$#qfiles]->{'status'} = $1;
-}
-elsif (/^\s+(\S+)/ && @qfiles) {
-$qfiles[$#qfiles]->{'to'} .= "$1 ";
-}
-}
+ next if (/^(\S+)\s+is\s+empty/i || /^\s+Total\s+requests:/i);
+ if (/^([^\s\*\!]+)[\*\!]?\s*(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+)\s+(.*)/) {
+ local $q = { 'id' => $1, 'size' => $2,
+ 'date' => $3, 'from' => $4 };
+ if (defined(&parse_mail_date)) {
+ local $t = &parse_mail_date($q->{'date'});
+ if ($t) {
+ $q->{'date'} = &make_date($t, 0, 'yyyy/mm/dd');
+ $q->{'time'} = $t;
+ }
+ }
+ push(@qfiles, $q);
+ }
+ elsif (/\((.*)\)/ && @qfiles) {
+ $qfiles[$#qfiles]->{'status'} = $1;
+ }
+ elsif (/^\s+(\S+)/ && @qfiles) {
+ $qfiles[$#qfiles]->{'to'} .= "$1 ";
+ }
+ }
close(MAILQ);
return @qfiles;
}
sub parse_queue_file
{
local @qfiles = ( &recurse_files("$config{'mailq_dir'}/active"),
- &recurse_files("$config{'mailq_dir'}/incoming"),
- &recurse_files("$config{'mailq_dir'}/deferred"),
- &recurse_files("$config{'mailq_dir'}/corrupt"),
- &recurse_files("$config{'mailq_dir'}/hold"),
+ &recurse_files("$config{'mailq_dir'}/incoming"),
+ &recurse_files("$config{'mailq_dir'}/deferred"),
+ &recurse_files("$config{'mailq_dir'}/corrupt"),
+ &recurse_files("$config{'mailq_dir'}/hold"),
);
local $f = $_[0];
local ($file) = grep { $_ =~ /\/$f$/ } @qfiles;
local ($mail, @headers);
&open_execute_command(QUEUE, "$config{'postcat_cmd'} ".quotemeta($file), 1, 1);
while(<QUEUE>) {
-if (/^\*\*\*\s+MESSAGE\s+CONTENTS/ && !$mode) { # Start of headers
-$mode = 1;
-}
-elsif (/^\*\*\*\s+HEADER\s+EXTRACTED/ && $mode) { # End of email
- last;
- }
-elsif ($mode == 1 && /^\s*$/) { # End of headers
- $mode = 2;
- }
-elsif ($mode == 1 && /^(\S+):\s*(.*)/) { # Found a header
- push(@headers, [ $1, $2 ]);
- }
-elsif ($mode == 1 && /^(\s+.*)/) { # Header continuation
- $headers[$#headers]->[1] .= $1 unless($#headers < 0);
- }
-elsif ($mode == 2) { # Part of body
- $mail->{'size'} += length($_);
- $mail->{'body'} .= $_;
+ if (/^\*\*\*\s+MESSAGE\s+CONTENTS/ && !$mode) { # Start of headers
+ $mode = 1;
+ }
+ elsif (/^\*\*\*\s+HEADER\s+EXTRACTED/ && $mode) { # End of email
+ last;
+ }
+ elsif ($mode == 1 && /^\s*$/) { # End of headers
+ $mode = 2;
+ }
+ elsif ($mode == 1 && /^(\S+):\s*(.*)/) { # Found a header
+ push(@headers, [ $1, $2 ]);
+ }
+ elsif ($mode == 1 && /^(\s+.*)/) { # Header continuation
+ $headers[$#headers]->[1] .= $1 unless($#headers < 0);
+ }
+ elsif ($mode == 2) { # Part of body
+ $mail->{'size'} += length($_);
+ $mail->{'body'} .= $_;
+ }
}
-}
close(QUEUE);
$mail->{'headers'} = \@headers;
foreach $h (@headers) {
-$mail->{'header'}->{lc($h->[0])} = $h->[1];
-}
+ $mail->{'header'}->{lc($h->[0])} = $h->[1];
+ }
return $mail;
}
return $rv;
}
-=head2 make_date(seconds, [date-only])
+=head2 make_date(seconds, [date-only], [fmt])
Converts a Unix date/time in seconds to a human-readable form, by default
-formatted like dd/mmm/yyyy hh:mm:ss.
+formatted like dd/mmm/yyyy hh:mm:ss. Parameters are :
+
+=item seconds - Unix time is seconds to convert.
+
+=item date-only - If set to 1, exclude the time from the returned string.
+
+=item fmt - Optional, one of dd/mon/yyyy, dd/mm/yyyy, mm/dd/yyyy or yyyy/mm/dd
=cut
sub make_date
{
-local ($secs, $only) = @_;
+local ($secs, $only, $fmt) = @_;
local @tm = localtime($secs);
local $date;
-local $fmt = $gconfig{'dateformat'} || 'dd/mon/yyyy';
+if (!$fmt) {
+ $fmt = $gconfig{'dateformat'} || 'dd/mon/yyyy';
+ }
if ($fmt eq 'dd/mon/yyyy') {
$date = sprintf "%2.2d/%s/%4.4d",
$tm[3], $text{"smonth_".($tm[4]+1)}, $tm[5]+1900;