Previous: FAQ 4-14, Up: FAQ 4 - Reading messages

##### Question 4.15

How to split incoming mails in several groups?

##### Answer

Gnus offers two possibilities for splitting mail, the easy nnmail-split-methods and the more powerful Fancy Mail Splitting. I'll only talk about the first one, refer to the manual, node "Fancy Mail Splitting" for the latter.

The value of nnmail-split-methods is a list, each element is a list which stands for a splitting rule. Each rule has the form "group where matching articles should go to", "regular expression which has to be matched", the first rule which matches wins. The last rule must always be a general rule (regular expression .*) which denotes where articles should go which don't match any other rule. If the folder doesn't exist yet, it will be created as soon as an article lands there. By default the mail will be send to all groups whose rules match. If you don't want that (you probably don't want), say

         (setq nnmail-crosspost nil)

in ~/.gnus.el.

An example might be better than thousand words, so here's my nnmail-split-methods. Note that I send duplicates in a special group and that the default group is spam, since I filter all mails out which are from some list I'm subscribed to or which are addressed directly to me before. Those rules kill about 80% of the Spam which reaches me (Email addresses are changed to prevent spammers from using them):

         (setq nnmail-split-methods
           '(("duplicates" "^Gnus-Warning:.*duplicate")
             ("XEmacs-NT" "^\\(To:\\|CC:\\).*localpart@xemacs.invalid.*")
             ("Gnus-Tut" "^\\(To:\\|CC:\\).*localpart@socha.invalid.*")
             ("tcsh" "^\\(To:\\|CC:\\).*localpart@mx.gw.invalid.*")
             ("BAfH" "^\\(To:\\|CC:\\).*localpart@.*uni-muenchen.invalid.*")
             ("Hamster-src" "^\\(CC:\\|To:\\).*hamster-sourcen@yahoogroups.\\(de\\|com\\).*")
             ("Tagesschau" "^From: tagesschau <localpart@www.tagesschau.invalid>$")
             ("Replies" "^\\(CC:\\|To:\\).*localpart@Frank-Schmitt.invalid.*")
             ("EK" "^From:.*\\(localpart@privateprovider.invalid\\|localpart@workplace.invalid\\).*")
             ("Spam" "^Content-Type:.*\\(ks_c_5601-1987\\|EUC-KR\\|big5\\|iso-2022-jp\\).*")
             ("Spam" "^Subject:.*\\(This really work\\|XINGA\\|ADV:\\|XXX\\|adult\\|sex\\).*")
             ("Spam" "^Subject:.*\\(\=\?ks_c_5601-1987\?\\|\=\?euc-kr\?\\|\=\?big5\?\\).*")
             ("Spam" "^X-Mailer:\\(.*BulkMailer.*\\|.*MIME::Lite.*\\|\\)")
             ("Spam" "^X-Mailer:\\(.*CyberCreek Avalanche\\|.*http\:\/\/GetResponse\.com\\)")
             ("Spam" "^From:.*\\(verizon\.net\\|prontomail\.com\\|money\\|ConsumerDirect\\).*")
             ("Spam" "^Delivered-To: GMX delivery to spamtrap@gmx.invalid$")
             ("Spam" "^Received: from link2buy.com")
             ("Spam" "^CC: .*azzrael@t-online.invalid")
             ("Spam" "^X-Mailer-Version: 1.50 BETA")
             ("Uni" "^\\(CC:\\|To:\\).*localpart@uni-koblenz.invalid.*")
             ("Inbox" "^\\(CC:\\|To:\\).*\\(my\ name\\|address@one.invalid\\|adress@two.invalid\\)")
             ("Spam" "")))