/usr/bin/mailsplit is in hxtools 20170430-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #!/usr/bin/perl
#
# written by Jan Engelhardt, 2007-2008
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the WTF Public License version 2 or
# (at your option) any later version.
#
use Getopt::Long;
use strict;
my $itable;
foreach my $file (@ARGV) {
if (!open(MBOX, "< $file")) {
print STDERR "Could not open $file: $!\n";
next;
}
my @data = split(/(?<=\n\n)(?=From)/s, join("", <MBOX>));
close MBOX;
my $folder = ".$file.split-up";
system "rm", "-Rf", $folder;
mkdir $folder;
open(FRAME, "> $file.html");
print FRAME "<html><frameset rows=\"*,*\"><frame src=\"$folder/idx.php\"><frame name=\"view\"></frameset>";
close FRAME;
open(INDEX, "> $folder/idx.php");
print INDEX <<"--EOT";
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
np,td{font-size:8pt;}
</style><body>
<table border=1>
<tr><th>#</th><th>From</th><th>To</th><th>Subject</th><th>Date</th></tr>
--EOT
my $i = 0;
foreach $_ (@data) {
my($from) = ($data[$i] =~ /^From:\s*(.*)/mi);
my($to) = ($data[$i] =~ /^To:\s*(.*)/mi);
my($subj) = ($data[$i] =~ /^Subject:\s*(.*)/mi);
my($date) = ($data[$i] =~ /^Date:\s*(.*)/mi);
my($from_addr) = ($from =~ /([\w\-_\.]+@[\w\-_\.]+)/mi);
my($to_addr) = ($to =~ /([\w\-_\.]+@[\w\-_\.]+)/mi);
$from =~ s/<.*?>//g;
$from = &dequote(&htmlize($from));
$to =~ s/<.*?>//g;
$to = &dequote(&htmlize($to));
$subj = &dequote(&htmlize($subj));
open(OUT, sprintf("> $folder/%06d.txt", $i));
print OUT $data[$i];
close OUT;
$itable = sprintf("<tr><td>%d</td><td><a href=\"mailto:%s\">".
"%s</td><td><a href=\"mailto:%s\">%s</a></td><td>".
"<a href=\"%06d.txt\" target=\"view\">%s</a></td>".
"<td>%s</td>\n",
$i, $from_addr, $from, $to_addr, $to, $i, $subj,
$date).
$itable;
++$i;
}
print INDEX <<"--EOT";
$itable
</table></body></html>
--EOT
close INDEX;
}
sub htmlize ()
{
my $a = shift @_;
$a =~ s/&/&/g;
$a =~ s/</</g;
$a =~ s/>/>/g;
return $a;
}
sub dequote ()
{
my $a = shift @_;
if ($a =~ s/=\?ISO.*?\?Q\?//) {
$a =~ s/=(..)/pack("H*", $1)/egi;
$a =~ s/\?=//g;
}
return $a;
}
|