Mailing List Archive

mh and qmail
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?
if not then
2) how do you configure it to use $HOME/mbox (obviously, I can wrapper inc
with maildir2mbox) ?
3) What tweaks are needed with mh and/or qmail in order to get outgoing
delivery working - mh uses SMTP to send outgoing mail, rather than invoking
sendmail (or replacement), and I'm sure someone somewhere said something needed
tweaking in order for some brokenness in mh to be overcome.

All help appreciated.

Timothy
Re: mh and qmail [ In reply to ]
> 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?
not that i know of.

> if not then
> 2) how do you configure it to use $HOME/mbox (obviously, I can wrapper inc
> with maildir2mbox) ?
i'll pass on this one -- i'm still letting qmail use mbox format, and doing
"inc +$foldername -file $filename" to move mail from an incoming mbox to
the right mh folder.

> 3) What tweaks are needed with mh and/or qmail in order to get outgoing
> delivery working - mh uses SMTP to send outgoing mail, rather than invoking
> sendmail (or replacement), and I'm sure someone somewhere said something needed
> tweaking in order for some brokenness in mh to be overcome.
you can do it two ways -- replace mts/sendmail/smail.c in the mh source
with the mh-smail.c-0.01 from ftp.qmail.org, and rebuild, or else replace
the /usr/bin/mh/post executable with /usr/bin/mh/spost (which you'll find
gets built by default when you build mh, though perhaps it isn't normally
installed), which purportedly accomplishes the same thing.

paul
---------------------
paul fox, pgf@foxharp.boston.ma.us (arlington, ma)
Re: mh and qmail [ In reply to ]
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.

> if not then
> 2) how do you configure it to use $HOME/mbox (obviously, I can wrapper inc
> with maildir2mbox) ?
> 3) What tweaks are needed with mh and/or qmail in order to get outgoing
> delivery working - mh uses SMTP to send outgoing mail, rather than invoking
> sendmail (or replacement), and I'm sure someone somewhere said something need
> ed
> tweaking in order for some brokenness in mh to be overcome.

Yes, it's in the latest version of the FAQ. Briefly, put:

postproc: /usr/local/nmh/lib/spost

into your ~/.mh_profile (adjusting for the correct lib directory of
course).

-Dom
Re: mh and qmail [ In reply to ]
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
}
Re: mh and qmail [ In reply to ]
> 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.

Hmm... actually, that's easily enough to hack to get it to work
with slocal (which takes mail from stdin and uses .maildelivery to decide
how to process it). I suppose all I need is to take each message from the
Maildir and then pass that to the "real" slocal along with all the
parameters supplied to the "fake" slocal. Then exmh should be able to use it
fine too :o)

This could work :o)

Thanks,

Timothy
Re: mh and qmail [ In reply to ]
> 2) how do you configure it to use $HOME/mbox (obviously, I can wrapper inc
> with maildir2mbox) ?

export MAILDROP=$HOME/mbox

> 3) What tweaks are needed with mh and/or qmail in order to get outgoing
> delivery working - mh uses SMTP to send outgoing mail, rather than invoking
> sendmail (or replacement), and I'm sure someone somewhere said something needed
> tweaking in order for some brokenness in mh to be overcome.

The only thing I needed to make it work was setting
localname: my.dom.ain
in /etc/mh/mtstailor (or /usr/lib/mh/mtstailor depending on the installation).

olaf
Re: mh and qmail [ In reply to ]
In message <199703191853.SAA28811@diamond.xara.net>, Timothy Hunt writes:
> Hmm... actually, that's easily enough to hack to get it to work
> with slocal (which takes mail from stdin and uses .maildelivery to decide
> how to process it). I suppose all I need is to take each message from the
> Maildir and then pass that to the "real" slocal along with all the
> parameters supplied to the "fake" slocal. Then exmh should be able to use it
> fine too :o)

What you would probably find far more flexible is using procmail
like this:

$ cat ~/.qmail
| preline /usr/local/bin/procmail
$

That way, every message gets piped through procmail, which has a
far more flexible method of deciding what to do with mail. In your
.procmailrc, you can pipe the message into rcvstore (like in your
.maildelivery), which will show up blue in exmh. Alternatively,
procmail can store mail directly in the folder, which won't show
up as blue in exmh. This is useful for automated mailings which
need archiving or lists which you don't stay on top of.

Of course, procmail will let you do all sorts of other things
with your mail as well. My colleague automatically gets paged
when certain mails arrive, which I've been looking into...

-Dom