Gnus Manual. Node: Mail and Procmail

PREVFancy Mail Splitting UPGetting Mail NEXTIncorporating Old Mail

6.3.5: Mail and Procmail

Many people use procmail (or some other mail filter program or external delivery agent---slocal, elm, etc) to split incoming mail into groups. If you do that, you should set nnmail-spool-file to procmail to ensure that the mail backends never ever try to fetch mail by themselves.

If you have a combined procmail/POP/mailbox setup, you can do something like the following:

(setq nnmail-use-procmail t)
(setq nnmail-spool-file
      '("/usr/spool/mail/my-name" "po:my-name"))

This also means that you probably don't want to set nnmail-split-methods either, which has some, perhaps, unexpected side effects.

When a mail backend is queried for what groups it carries, it replies with the contents of that variable, along with any groups it has figured out that it carries by other means. None of the backends, except nnmh, actually go out to the disk and check what groups actually exist. (It's not trivial to distinguish between what the user thinks is a basis for a newsgroup and what is just a plain old file or directory.)

This means that you have to tell Gnus (and the backends) by hand what groups exist.

Let's take the nnmh backend as an example:

The folders are located in nnmh-directory, say, `~/Mail/'. There are three folders, `foo', `bar' and `mail.baz'.

Go to the group buffer and type G m. When prompted, answer `foo' for the name and `nnmh' for the method. Repeat twice for the two other groups, `bar' and `mail.baz'. Be sure to include all your mail groups.

That's it. You are now set to read your mail. An active file for this method will be created automatically.

If you use nnfolder or any other backend that store more than a single article in each file, you should never have procmail add mails to the file that Gnus sees. Instead, procmail should put all incoming mail in nnmail-procmail-directory. To arrive at the file name to put the incoming mail in, append nnmail-procmail-suffix to the group name. The mail backends will read the mail from these files.

When Gnus reads a file called `mail.misc.spool', this mail will be put in the mail.misc, as one would expect. However, if you want Gnus to split the mail the normal way, you could set nnmail-resplit-incoming to t.

If you use procmail to split things directly into an nnmh directory (which you shouldn't do), you should set nnmail-keep-last-article to non-nil to prevent Gnus from ever expiring the final article (i.e., the article with the highest article number) in a mail newsgroup. This is quite, quite important.

Here's an example setup: The incoming spools are located in `~/incoming/' and have `""' as suffixes (i.e., the incoming spool files have the same names as the equivalent groups). The nnfolder backend is to be used as the mail interface, and the nnfolder directory is `~/fMail/'.

(setq nnfolder-directory "~/fMail/")
(setq nnmail-spool-file 'procmail)
(setq nnmail-procmail-directory "~/incoming/")
(setq gnus-secondary-select-methods '((nnfolder "")))
(setq nnmail-procmail-suffix "")
PREVFancy Mail Splitting UPGetting Mail NEXTIncorporating Old Mail