procmail
[Top] [All Lists]

Re: emacs rmail + procmail, FAQ?

1997-03-19 09:31:23
Excerpts from mail: (18-Mar-97) emacs rmail + procmail, FAQ? by David Tillman
    This may be a FAQ, but here goes: What is the safest procedure to
follow in order to read procmail folders with rmail under emacs?

For procmail and Emacs' RMAIL to work together safely (especially in an NFS
environment), you must:

(1) specify a procmail local lock file with extension ".lock" on each inbox

(2) ensure that all mail delivery occurs within a single directory that is
    specified by the Emacs Lisp variable `rmail-spool-directory' (actually,
    versions of Emacs >= 19.29 do not have this limitation)

(3) ensure that Emacs' movemail is properly configured to recognize .lock files

Here's how to test to see if your movemail works correctly with .lock files
or not: (Do this in the directory where you keep your mail files before RMAIL
reads them.)

% echo "Testing." > foo
% lockfile foo.lock
% ls -l
total 2
-rw-r--r--  1 sabol           9 Aug 30 14:28 foo
-r--r--r--  1 sabol           1 Aug 30 14:29 foo.lock
% /usr/local/libexec/emacs/19.34/sparc-sun-sunos4.1.3/movemail foo bar

OK, after you do that, if the directory listing looks like this:

% ls -l
total 1
-rw-r--r--  1 sabol           9 Aug 30 14:35 bar
-rw-r--r--  1 sabol           0 Aug 30 14:35 foo

... then that means movemail just ignored lockfile's .lock semaphore file!
This means movemail was compiled to use either lockf() or flock(). If your
home directory or mail spool directory is NFS-mounted, you should reconfigure
and recompile movemail to use .lock files instead. This is the way it is
supposed to work:

% ls -l
total 2
-rw-r--r--  1 sabol           9 Aug 30 14:35 foo
-r--r--r--  1 sabol           1 Aug 30 14:39 foo.lock
% ~/bin/movemail foo bar &
[1] 187
% ls -l
total 2
-rw-r--r--  1 sabol           9 Aug 30 14:41 foo
-r--r--r--  1 sabol           1 Aug 30 14:41 foo.lock
% rm -f foo.lock 
% [1]    Done                   ~/bin/movemail foo bar
ls -l
total 1
-rw-r--r--  1 sabol           9 Aug 30 14:41 bar
-rw-r--r--  1 sabol           0 Aug 30 14:41 foo

Perhaps the most reliable method is to create a wrapper script around a
movemail configured to use either lockf() or flock(). The wrapper script
would recognize and create .lock semaphore files using procmail's 'lockfile'.
This would give you the best of both worlds and be the most reliable. I
actually did this for a while, but it really slows down fetching new mail. I
finally got fed up with it and asked my system administrators for the
movemail source code and compiled my own version that uses .lock files. If
you can get your hands on the source code to movemail, just add these two
lines up near the top after all the #includes and before the "#ifdef
MAIL_USE_LOCKF":

#undef MAIL_USE_LOCKF
#undef MAIL_USE_FLOCK

Once you've recompiled the `movemail' source code and confirmed that the
above test now works, you'll need to set a RMAIL variable to tell RMAIL that
you want to use this alternative `movemail' instead of the one that comes
with Emacs. This variable is `rmail-movemail-program'. Gnus and VM have a
similarly named variables, by the way.

I suggest you have procmail deliver your mail to inboxes located at ~/Mail/
(or ~/mail/ or whatever you prefer). For example, I subscribe to the procmail
mailing list. I have procmail file incoming procmail-related e-mail to
~/Mail/procmail.spool. Let's say you do the same thing. If you create a blank
RMAIL file named ~/Mail/procmail and load it into Emacs, just `M-x
set-rmail-inbox-list' and specify ~/Mail/procmail.spool as the inbox. Now,
whenever you are in the *procmail* or *procmail-summary* buffer, hitting `g'
will retrieve the e-mail in ~/Mail/procmail.spool using movemail and it
will be incorporated into the procmail RMAIL file.

Hope this has helped,
Ed

<Prev in Thread] Current Thread [Next in Thread>