Gnus development mailing list
 help / color / mirror / Atom feed
* splitting based on BBDB
@ 2002-01-31 19:51 NAGY Andras
  0 siblings, 0 replies; only message in thread
From: NAGY Andras @ 2002-01-31 19:51 UTC (permalink / raw)


I have made a nifty little hack to split my mail partly based on info
in BBDB.  Yes, I am aware of the similar thing in bbdb-gnus.el, but
this is something different.  :-)

,----[ Code ]
| ;; Utility function for mail splitting
| (defun my-split-bbdb (property split)
|   "Search the BBDB for the sender of message in the current buffer.
| Return nil if not found.  Return the field indicated by `property' of
| the record, if that field exists.  Return `split' otherwise."
| 
|   (let* ((field (mail-fetch-field "from"))
| 	 (from (mail-extract-address-components field))
| 	 (nam (car from))
| 	 (net (car (cdr from)))
| 	 (net (if (and net bbdb-canonicalize-net-hook)
| 		  (bbdb-canonicalize-address net)
| 		net))
| 	 (rec (bbdb-search-simple nam net)))
|     
|     (if rec
| 	(or (bbdb-record-getprop rec property) split)
|       nil)))
`----

,----[ Example usage ]
| (setq nnmail-split-methods 'nnmail-split-fancy
|       nnmail-split-fancy
|       '(|
| 
|         [...mailing lists et al...]
| 
| 	(: my-split-bbdb 'gnus-split "mail.misc")
| 	("from" ".*@.*\\.hu" "mail.misc")
| 	"mail.unknown"))
`----

With these splitting rules, I get the following behavior: if someone
appears in my BBDB and has a gnus-split property, mail from him will
be stored in that group.  If no such property exists, mail will be
stored in the catch-all group.  Mail matching certain criteria (the
sender address is from the .hu domain in the above example, but of
course, this could be anything) is also stored in the catch-all group,
because I perceived I rarely get spam matching this criteria.
Everything else is stored in the the `unknown' group.  This actually
eliminates all of the spam from the catch-all group, and hopefully
very few non-spam mail will end up in the `unknown' group.


Andras



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-01-31 19:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-31 19:51 splitting based on BBDB NAGY Andras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).