Re: Checking from an external file?
Milan Obuch <[email protected]> Mon, 19 May 2025 11:27:28 +0200
| Newsgroups | gmane.mail.maildrop |
|---|---|
| Message-ID | <[email protected]> |
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... 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. 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. 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. 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 (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). > > I think you need more experiments to get something out of this. In > > particular, I recommend reading 'man maildropfilter', where you can > > find 'lookup' function, which can be better suited for your use > > case (I don't know whether you like matching the subject exactly, > > or do some pattern matching, those are completely different animals > > and come with different considerations). > > > 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. Regards, Milan