Re: Checking from an external file?
Philip Rhoades via Courier-maildrop <[email protected]> Tue, 20 May 2025 00:51:34 +1000
| Newsgroups | gmane.mail.maildrop |
|---|---|
| Message-ID | <[email protected]> |
Milan, On 2025-05-19 19:27, Milan Obuch wrote: > On Mon, 19 May 2025 18:55:43 +1000 > Philip Rhoades via Courier-maildrop > <[email protected]> wrote: > >> Milan, >> >> Progress! - see below . . > > [ snip ] > >> No errors now . . and mail is delivered but only to the standard >> maildir: >> >> I tried these: >> >> Luxury Watch #13 >> Subject: Luxury Watch #13 >> "Subject: Luxury Watch #13" subject >> >> in .list but I still get: >> >> MAILDIR="" >> >> I guess I am getting the syntax wrong in the .list file for the key >> value lookup? >> > > Is there something in maillog connected to delivery process of a given > mail? For mail test done by direct maildrop call from shell, probably > something is printed to stdout... Yes, I have output in: ~/.getmail/.maildrop.log and I keep the output of the mailfilter stuff directly in: Maildir/maildrop.logs > Back to your original question - whether it is possible to use file for > a list of values to do some lookup, I gave an example how it could be > done. You did not state purpose of doing so, so maybe my example was > not exactly suitable for your use case, which I did not wrote what > purpose it servers. Yes, I didn't quite realise what your own code was attempting to do - clearer now . . > So to fix that, my example was how could a mail be delivered in a > folder designated for a maling list posts in a general way, without > necesity to edit a .mailfilter on every mailing list addition or > deletion to the list of mailing lists I am subscribed to, and I wish to > store the communacation in a dedicated folder. Right. > Mailing list software usually identified posts distributed by list by > adding some mail headers in process of delivering mails. That was > List-Id in my case, the (probably) most common one. Right. > What you are trying to do, is classify a subject of mail by presence of > some strings, and then, probably do some alternate folder delivery Correct. > (I > do not recommend drop mail to floor this way instead, as you can loose > good non spam mail without possibility to fix that short of letting > sender know of necessity to repost a message with different subject). No, I wouldn't just drop mails - I have a collection of about 10k spam mails (which keeps getting bigger) that I have kept that I thought might be useful sometime - like now! >> Yes, I will look at that - I think once I have he DB working it >> should greatly simplify what I do. Also, yes, I would prefer to use >> regexes instead of exact matches for the Subjects . . >> > > That's what 'lookup' function does - so getting an example from man > page and adjusting it a bit to your situation (or my understanding of > it) I would test following snippet: > > if (/^Subject:\s*(.*)/ && lookup($MATCH1,'badsubject')) > {exception {to "$HOME/Maildir/.somefolder" > } > } > > In file 'badsubject' you place a list of regexps, one per line, to test > your subject against, if a match is found, mail should be placed into > 'somefolder' located just below Inbox in your mailbox (maildir, to be > exact), provided such folder does exist. > > I think this matches a bit better your intention than my original > example, if not, more material for testing (and thinking about it, this > part is important) is provided. OK, this appears to be working! (more testing and particularly with lots of lines in .badsubject): if (/^Subject: *(.*)/) { if (gdbmopen('.badsubject.db','R')) echo 'gdbmopen error R1' else { if (/^Subject:\s*(.*)/ && lookup($MATCH1,'.badsubject')) {exception {to "$HOME/Maildir/.INBOX.1" } } } } if (gdbmopen('.badsubject.db','N')) echo 'gdbmopen error N1' else { foreach (`cat $HOME/.badsubject`) =~ /\S+\s+\S+/ { $MATCH =~ /(\S+)\s+(\S+)/; if (gdbmstore($MATCH1,$MATCH2)) echo "gdbm $MATCH1 => $MATCH2 problem!" } gdbmclose } Thanks for all your help - it has been greatly appreciated! Regards, Phil. -- Philip Rhoades PO Box 896 Cowra NSW 2794 Australia E-mail: [email protected]