1. Archiving sent mail
I needed to archive sent mail with MHonArc and I needed to put
contents of To: header to mesage index. It was not possible with
MHonArc-2.5.13 so I wrote a small patch that added rc-variable $TO$.
Then I used
<LiTemplate>
<li><strong>$SUBJECT$</strong><br>
$MSGLOCALDATE(CUR;%Y-%m-%d %H:%M)$<br>
<em>From</em>: $FROM$<br>
<em>To</em>: $TO$
</li>
</LiTemplate>
Check the attached file MHonArc-2.5.13-to.patch.
2. Attachmants with non-ascii names
I had problems with accessing attachments extracted with MHonArc from
Windows if they had non-ascii characters in name or characters
forbidden for file names: \/:*?"<>| (when using m2h_external::filter;
usename).
So I have written a patch that converts both types of characters to
underscore, just like spaces in original MHonArc.
Check the attached file MHonArc-2.5.13-attachment_name.patch.
3. Preserving charset of message
Most mails I have to convert use central european ISO-8859-2
encoding. Converting it to named entities did not work - it lacks
browsers support. Using UTF-8 would make my archives un-grep-able so
I wrote a patch that made possible that text/plain MIME-parts
preserve original charset by adding rc-variable $CHARSET$.
Then I could use:
<MsgPgBegin>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>$SUBJECTNA$</title>
<link rev="made" href="mailto:$FROMADDR$">
<meta http-equiv="Content-Type" content="text/html; charset=$CHARSET$">
</head>
<body>
</MsgPgBegin>
I've attached the patch: MHonArc-2.5.13-charset.patch.
I'm not a perl programmer so this patches are far from being perfect.
Mostly done by copy-paste/little-change technique. But they work good
enough to allow me to convert some people's mail to HTML format, so I
could burn it on CD and give them.
I think MHonArc needs this functionality so it can be used not only
for archiving mailing list.
I'm not a good english speaker so please forgive me language errors
or not very sophisticated vocabulary :-)
Best wishes
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
Winnie the Pooh
diff -urP MHonArc2.5.13.orig/lib/mhamain.pl MHonArc2.5.13/lib/mhamain.pl
--- MHonArc2.5.13.orig/lib/mhamain.pl Mon Oct 21 19:02:06 2002
+++ MHonArc2.5.13/lib/mhamain.pl Mon Dec 16 21:11:01 2002
@@ -719,7 +719,7 @@
sub read_mail_header {
my $handle = shift;
my($index, $date, $tmp, $i, $field, $value);
- my($from, $sub, $msgid, $ctype);
+ my($from, $sub, $msgid, $ctype, $to);
local($_);
my @refs = ();
@@ -842,6 +842,17 @@
}
$from = 'Unknown' unless $from;
+ ##----------##
+ ## Get To ##
+ ##----------##
+ $to = "";
+ foreach ('to') {
+ next unless defined $fields->{$_};
+ $to = $fields->{$_}[0];
+ last;
+ }
+ $from = 'Unknown' unless $from;
+
##----------------##
## Get References ##
##----------------##
@@ -888,6 +899,7 @@
}
$From{$index} = $from;
+ $To{$index} = $to;
$Date{$index} = $date;
$Subject{$index} = $sub;
$MsgHead{$index} = htmlize_header($fields);
@@ -1330,6 +1342,7 @@
delete $ContentType{$key};
delete $Date{$key};
delete $From{$key};
+ delete $To{$key};
delete $IndexNum{$key};
delete $Refs{$key};
delete $Subject{$key};
diff -urP MHonArc2.5.13.orig/lib/mhrcvars.pl MHonArc2.5.13/lib/mhrcvars.pl
--- MHonArc2.5.13.orig/lib/mhrcvars.pl Sat Jul 27 07:13:13 2002
+++ MHonArc2.5.13/lib/mhrcvars.pl Mon Dec 16 21:11:01 2002
@@ -143,6 +143,13 @@
$tmp = defined($key) ? &$esub($From{$key}) : "(nil)";
last REPLACESW;
}
+ if ($var eq 'TO') { ## Message "To:"
+ my $esub = sub { $_[0]; };
+ $canclip = 1; $raw = 1;
+ ($lref, $key, $pos) = compute_msg_pos($index, $var, $arg);
+ $tmp = defined($key) ? &$esub($To{$key}) : "(nil)";
+ last REPLACESW;
+ }
if ( ($cnd1 = ($var eq 'FROMADDRNAME')) ||
($cnd2 = ($var eq 'FROMADDRDOMAIN')) ) {
($lref, $key, $pos) = compute_msg_pos($index, $var, $arg);
diff -urP MHonArc2.5.13.orig/lib/mhmimetypes.pl MHonArc2.5.13/lib/mhmimetypes.pl
--- MHonArc2.5.13.orig/lib/mhmimetypes.pl Thu Sep 26 04:52:53 2002
+++ MHonArc2.5.13/lib/mhmimetypes.pl Mon Dec 16 21:14:27 2002
@@ -307,6 +307,8 @@
## Else, filename given
} else {
$fname =~ tr/ \t\n\r/_/; # Convert spaces to underscore
+ $fname =~ tr/\134\57\72\52\77\42\74\76\174/_/; # Convert characters forbidden
+by Windows (\/:*?"<>|) to underscore
+ $fname =~ tr/\177-\377/_/; # Convert characters over 127 to underscore
}
## Set pathname for file
diff -urP MHonArc2.5.13.orig/lib/mhrcvars.pl MHonArc2.5.13/lib/mhrcvars.pl
--- MHonArc2.5.13.orig/lib/mhrcvars.pl Sat Jul 27 07:13:13 2002
+++ MHonArc2.5.13/lib/mhrcvars.pl Mon Dec 16 21:12:30 2002
@@ -195,6 +195,16 @@
$tmp = defined($key) ? $Index2MsgId{$key} : "";
last REPLACESW;
}
+ if ($var eq 'CHARSET') { ## Message charset
+ my $esub = sub { $_[0]; };
+ $canclip = 1; $raw = 1;
+ ($lref, $key, $pos) = compute_msg_pos($index, $var, $arg);
+ $tmp = defined($key) ? &$esub($Charset{$key}) : "us-ascii";
+ if ( $tmp eq "" ) {
+ $tmp = "us-ascii";
+ }
+ last REPLACESW;
+ }
if ($var eq 'MSGLOCALDATE') { ## Message local date
($lref, $key, $pos, $opt) = compute_msg_pos($index, $var, $arg);
$tmp = &time2str($opt || $MsgLocalDateFmt,
diff -urP MHonArc2.5.13.orig/lib/mhtxtplain.pl MHonArc2.5.13/lib/mhtxtplain.pl
--- MHonArc2.5.13.orig/lib/mhtxtplain.pl Fri Oct 11 00:27:19 2002
+++ MHonArc2.5.13/lib/mhtxtplain.pl Mon Dec 16 21:12:30 2002
@@ -247,6 +247,7 @@
} else {
$charset = $defset;
}
+ $mhonarc::Charset{$mhonarc::MHAindex} = $charset;
## Grab format parameter (if defined)
if ( defined($fields->{'content-type'}[0]) and
$fields->{'content-type'}[0] =~ /\bformat\s*=\s*([^\s;]+)/i ) {