You write:
>Timothy Hunt wrote:
>> I'm sure this has been asked before, but I cant' seem to find the details on
>> the list.
>>
>> 1) has mh been patched to use Maildir?
>
>Nope. nmh is working on it, but no progress yet.
Here's what I use. It works for me; it may or may not work for you!
qinc moves files straight from the maildir into +inbox (or other specified
folder). I wrote this after I got tired of getting duplicate email when
new mail arrived in the middle of running inc.
Eric Krohn
% cat ~/.qmail
/u/krohn/Maildir/
|echo >> /u/krohn/Maildir/biff
% echo $MAIL
/u/krohn/Maildir/biff
% cat /usr/local/bin/qinc
# Very stripped down inc(1) replacement that understands qmail's Maildir
# format.
# Copyright 1996, Eric Krohn. This may be freely copied. Mail fixes to eric@krohn.com.
# @(#)qinc 1.3
eval 'exec perl -S $0 ${1+"$@"}'
if $running_some_shell;
($Command = $0) =~ s,^.*/,,;
$verbose = 0;
$HOME = $ENV{"HOME"};
$MailDrop = $HOME."/Maildir";
$MailPath = $HOME."/Mail";
$folder = "inbox";
$silent = "-nosilent";
$pack = "-nopack";
$audit = "-noaudit";
$changecur = "-changecur";
$mh_profile = defined $ENV{"MH"} ? $ENV{"MH"} =~ m,^/, ? $ENV{"MH"} : $HOME."/".$ENV{"MH"} : $HOME."/.mh_profile";
@scan_options = ();
&read_mh_profile ($mh_profile);
while ($#ARGV >= 0) {
$_ = shift (@ARGV);
if (/^--$/) { }
elsif (/^-\?$/ || /^-help$/) { &Usage (); }
elsif (/^\+(\S+)$/) { $folder = $1; }
elsif (/^-(no)?silent$/) { $silent = $_; }
elsif (/^-verbose$/) { $verbose++; }
elsif (/^-(no)?changecur$/) { $changecur = $_; }
elsif (/^-file$/) { $MailDrop = shift (@ARGV); }
# Pass through options.
elsif (/^-form$/) { push (@scan_options, $_, shift (@ARGV)); }
elsif (/^-format$/) { push (@scan_options, $_, shift (@ARGV)); }
elsif (/^-width$/) { push (@scan_options, $_, shift (@ARGV)); }
# inc(1) options that are purposely ignored.
elsif (/^-(no)?notruncate$/) { $truncate = $_; }
# inc(1) options that are not yet implemented
elsif (/^-audit$/) { $audit = shift (@ARGV); }
elsif (/^-noaudit$/) { undef $audit; }
elsif (/^-host$/) { $host = shift (@ARGV); }
elsif (/^-user$/) { $user = shift (@ARGV); }
elsif (/^-(no)?apop$/) { $apop = $_; }
elsif (/^-(no)?rpop$/) { $rpop = $_; }
elsif (/^-pack$/) { $pack = shift (@ARGV); }
elsif (/^-nopack$/) { undef $pack; }
else { &Usage ("unknown argument: $_"); }
}
$exit = 0;
die ("no $MailDrop") if (! -d $MailDrop);
die ("no $MailDrop/new") if (! -d "$MailDrop/new");
chdir ("$MailDrop/new") || die ("$Command: cannot chdir to $MailDrop/new: $!");
opendir (NEW, ".") || die ("$Command: cannot opendir $MailDrop/new: $!");
@files = ();
while ($file = readdir (NEW)) {
if (! -f $file) { next; }
if ($file !~ /^\d+\.\d+\.\S+$/) {
# Might be a bit drastic.
#unlink $file;
next;
}
push (@files, $file);
}
closedir (NEW);
$folderpath = "$MailPath/$folder";
# Find highest numbered message.
$last = 0;
opendir (INBOX, "$folderpath") || die ("$Command: cannot opendir $folderpath: $!");
while ($file = readdir (INBOX), defined $file) {
if ($file =~ /^\d+$/ && $file > $last) {
$last = $file;
}
}
closedir (INBOX);
print ("last message in $folderpath is $last\n") if ($verbose);
# Now refile the messages into +$folder.
# Since inc sets cur to the first message, incorporated, we must do the same
# and update .mh_sequences.
$next = $last;
undef $cur;
for $file (sort @files) {
$next++;
print ("link $file -> $folderpath/$next\n") if ($verbose);
rename ($file, "$folderpath/$next")
|| (system ("mv", $file, "$folderpath/$next") != 0)
|| die ("cannot rename/mv $file -> $folderpath/$next: $!");
if (!defined $cur) {
$cur = $next;
}
}
if (-f "$MailDrop/biff") {
#local ($now) = time;
#utime $now, $now, "$MailDrop/biff";
# Truncate biff.
open (BIFF, "> $MailDrop/biff");
close (BIFF);
}
if ($changecur eq "-changecur") {
&update_mh_sequences ();
}
if ($silent =~ /^-nosilent$/) {
system ("scan", "+$folder", @scan_options, "$cur-last");
}
exit $exit;
##################
sub update_mh_sequences
{
$seq = '';
open (SEQ, "$folderpath/.mh_sequences");
while ($_ = <SEQ>) {
if (/cur: \d+/) { $seq .= "cur: $cur\n"; }
else { $seq .= $_; }
}
close (SEQ);
unlink "$folderpath/.mh_sequences.new";
open (NEWSEQ, "> $folderpath/.mh_sequences.new") || ++$exit;
print NEWSEQ ($seq) || ++$exit;
close (NEWSEQ) || ++$exit;
if ($exit == 0) {
unlink "$folderpath/.mh_sequences" &&
rename "$folderpath/.mh_sequences.new", "$folderpath/.mh_sequences";
}
}
sub read_mh_profile
{
local ($file) = @_;
local ($_);
open (FILE, $file); # do not worry if open fails.
while ($_ = <FILE>) {
chop;
if (/^Path:\s*(\S+)/) {
$MailPath = $1;
$MailPath =~ s,^[^/],$HOME/$&,;
}
elsif (s/^inc:\s*//) {
unshift (@ARGV, split (/\s+/, $_));
}
elsif (/^MailDrop:\s*(\S+)/) {
$MailDrop = $1;
}
elsif (/^Inbox:\s*(\S+)/) {
$folder = $1;
}
}
close (FILE);
}
sub Usage
{
for $_ (@_) { print STDERR ("$Command: $_\n"); }
die (<<"USAGE");
Usage: $Command [options] file ...
$Command is a very stripped down inc(1) replacement that understands
qmail's Maildir format. Since qmail Maildir format stores each message as
separate file, $Command actually renames each message to move the mail
into the inbox folder.
If there is a file named biff in the Maildir, then it will be truncated so
that biff and xbiff will work.
Options:
-maildir dir Use dir as the MailDrop instead of $MailDrop.
-[no]silent Work silently or not.
-file maildir Use maildir as the Maildir.
+folder Deposit new mail into folder instead of $folder.
-verbose Work verbosely.
-[no]changecur Change current message. Default is $changecur.
-[no]silent Work silently. Default is $silent.
The following inc options are recognized but ignored:
-[no]truncate $Command always removes the messages from Maildir/new
after being filed.
-audit file
-noaudit
-pack file
-nopack
-host name
-user name
-[no]apop
-[no]rpop
USAGE
}