Re: Checking from an external file?
Milan Obuch <[email protected]> Sun, 18 May 2025 08:29:34 +0200
| Newsgroups | gmane.mail.maildrop |
|---|---|
| Message-ID | <[email protected]> |
On Sun, 18 May 2025 10:50:33 +1000 Philip Rhoades via Courier-maildrop <[email protected]> wrote: > People, > > Part of my .mailfilter looks like this: > > # .spam ^Subject: Uppper {{{3 > if ( /^Subject: INQ /:h \ > || /^Subject: \(/:h \ > || /^Subject: (Top|Luxury) Watches/:h \ > || /^Subject: 180/:h \ > || /^Subject: 4mJ/:h \ > || /^Subject: =?UTF/:h \ > || /^Subject: ? eat this.../:h \ > || /^Subject: \*\*/:h \ > || /^Subject: \.You/:h \ > || /^Subject: \[CONFINDENTIAL\]/:h \ > || /^Subject: \[Mayo Clinic Research\]/:h \ > || /^Subject: A .*(reverse|Daily).*(payment|Sprinkle)/:h \ > || /^Subject: Action Required/:h \ > || /^Subject: ACH/:h \ > || /^Subject: ACTIVEZ/:h \ > > etc. > > Is it possible to have a separate file with all the lines in so that > section of .mailfilter could be reduced to something like: > > # .spam ^Subject: Uppper {{{3 > if ( /^Subject: "/home/phr/Maildir/spam_upper.txt" /:h ) > > ? > Why not? I am doing something similar with List-Id header, simplified version here: if (/^List-Id: *(.*)/) {ListId = $MATCH1 if ($ListId =~ /.*\<(.*)\>/) ListId = $MATCH1 if (gdbmopen('.list.db','R')) echo 'gdbmopen error R1' else {MAILDIR = gdbmfetch($ListId) gdbmclose if ($MAILDIR) {exception {to "$HOME/Maildir/$MAILDIR/" } } } } File .list.db contains mappings from mailing list header to maildir folder, it is created from .list text file, containing List-Id and maildir folder name delimited by spaces/tabs, which, for this list, is courier-maildrop.lists.sourceforge.net .Software.Courier.courier-maildrop This file is converted into .list.db with following code: {if (gdbmopen('.list.db','N')) echo 'gdbmopen error N1' else {foreach (`cat $HOME/.list`) =~ /\S+\s+\S+/ {$MATCH =~ /(\S+)\s+(\S+)/; if (gdbmstore($MATCH1,$MATCH2)) echo "gdbm $MATCH1 => $MATCH2 problem!" } gdbmclose } } (yes, in maildrop - it is triggered when .list file is changed) I have 101 lines in my .list file, so while its handling looks somewhat complex, it is simpler to maintain long-term... and when I created this, I was willing to spend some time to learn things and automatize mail processing when possible. Also, this maildrop recipe could be made global, so you could customise your filtering experience per maildir/user, just by creating .list file in your home directory. Regards, Milan