#!/usr/local/bin/perl # view_mailq.cgi # Display some message from the mail queue require './postfix-lib.pl'; require './boxes-lib.pl'; &ReadParse(); $access{'mailq'} || &error($text{'mailq_ecannot'}); $mail = &parse_queue_file($in{'id'}); $mail || &error($text{'mailq_egone'}); &parse_mail($mail); @sub = split(/\0/, $in{'sub'}); $subs = join("", map { "&sub=$_" } @sub); foreach $s (@sub) { # We are looking at a mail within a mail .. local $amail = &extract_mail($mail->{'attach'}->[$s]->{'data'}); &parse_mail($amail); $mail = $amail; } if (!@sub) { $desc = &text('view_qdesc',"$in{'id'}"); } else { $desc = $text{'view_sub'}; } &ui_print_header($desc, $text{'view_title'}, ""); print "
\n"; print "\n"; print "\n"; print "\n"; print "
", "\n"; if ($in{'headers'}) { print "\n"; } else { print "\n"; } print "
$text{'view_headers'}$text{'view_noheaders'}$text{'view_allheaders'}
\n"; if ($in{'headers'}) { # Show all the headers if ($mail->{'fromline'}) { print "", "\n"; } foreach $h (@{$mail->{'headers'}}) { print " ", "\n"; } } else { # Just show the most useful headers print " ", "\n"; print " ", "\n"; print " ", "\n" if ($mail->{'header'}->{'cc'}); print " ", "\n"; print " ", "\n"; } print "
$text{'mail_rfc'}",&html_escape($mail->{'fromline'}),"
$h->[0]:",&html_escape(&decode_mimewords($h->[1])), "
$text{'mail_from'}",&html_escape($mail->{'header'}->{'from'}),"
$text{'mail_to'}",&html_escape($mail->{'header'}->{'to'}),"
$text{'mail_cc'}",&html_escape($mail->{'header'}->{'cc'}),"
$text{'mail_date'}",&html_escape($mail->{'header'}->{'date'}),"
$text{'mail_subject'}",&html_escape( $mail->{'header'}->{'subject'}),"

\n"; # Find body attachment @attach = @{$mail->{'attach'}}; foreach $a (@attach) { if ($a->{'type'} eq 'text/plain') { $body = $a; last; } } if ($body) { print "
\n";
	foreach $l (&wrap_lines($body->{'data'}, $config{'wrap_width'})) {
		print &link_urls_and_escape($l),"\n";
		}
	print "

\n"; } # Display other attachments @attach = grep { $_ ne $body } @attach; @attach = grep { !$_->{'attach'} } @attach; if (@attach) { print "\n"; print "\n"; print "
$text{'view_attach'}
\n"; foreach $a (@attach) { if ($a->{'type'} eq 'message/rfc822') { push(@titles, $text{'view_sub'}); push(@links, "view_mailq.cgi?id=$in{'id'}$subs&sub=$a->{'idx'}"); } else { push(@titles, $a->{'filename'} ? &decode_mimewords($a->{'filename'}) : $a->{'type'}); push(@links, "detach_queue.cgi?id=$in{'id'}&attach=$a->{'idx'}$subs"); } push(@icons, "images/boxes.gif"); } &icons_table(\@links, \@titles, \@icons, 8); print "

\n"; } # Display buttons if (!@sub) { print "\n"; print "

\n"; } print "

\n"; &ui_print_footer(!@sub ? ( ) : ( "view_mailq.cgi?id=$in{'id'}", $text{'view_return'} ), "mailq.cgi", $text{'mailq_return'}, "", $text{'index_return'});