why won't procmail do what I want it to?
January 13, 2006 6:50 AM   Subscribe

I have a few questions about procmail, specifically the INCLUDERC command and a few other functions.

1. I use procmail (v3.22), along with elm (v2.5), for email. My recipe works basically fine, but I want to make it easier to update and maintain when I want to whitelist someone or blacklist a term, so I want to use separate recipe files to split out the different functions. So, using INCLUDERC, I built a few of these files but procmail seems to just skip them, at least as far as I can tell by having VERBOSE set to on. What are some common things I might be doing that would cause this? I've checked the filenames, file permissions and file paths and I'm sort of stumped.

2. I have a domain that is the same as my name. Way back when I used to put a lot of custom mailto links on my website. These are all now spam cannons and mail to these addresses can safely be ported to /dev/null. I've read that you can create OR queries in procmail just by doing something like this

:0 H
* ^To.*crazynutpostcardlady
* ^To.*barthrulz
:0 fhw
| formail -A "Suspected_Spam: To... bad address" # a relic from the rest of my script

but when I do it, procmail reads the first address and then goes on to the next condition. If I break them out separately, as I do in my procmail script, it's fine, but a bitch to update. I've been reading FAQs all day but I feel that there is clearly something I'm missing about how procmail operates. I'm comfy in a unix shell but otherwise don't have a lot of coding background so regexps are sort of new for me.

I may migrate to spam assassin or something else at some point, but for now I'm just looking for help with either of these two puzzles so please, no general mail filtering advice unless it helps me make this recipe better. Thanks for helping me with procmail.
posted by jessamyn to Computers & Internet (9 answers total)
Multiple conditions in a recipe should work as AND rather than OR.

To get OR conditions, you could plop everything on one line like so:

* ^To.*(crazynutpostcardlady|barthrulz)

But that sounds really tedious.

A better solution is to use scoring to create a set of conditions that will each be checked in turn, providing a total score at the end to determine a match.

:0 H
* 1^0 ^To.*crazynutpostcardlady
* 1^0 ^To.*barthrulz

That will score each line that's a match as 1. Procmail will then consider the total and if it's 1 or higher consider it a match for the rule.

I'm not sure what your issue with INCLUDERC is. Could I see your .procmailrc headers and your INCLUDERC statements?
posted by ursus_comiter at 7:23 AM on January 13, 2006

I basically use INCLUDERC=$HOME/.virusrc on its own line with the rest of the headers (the rest of the script is linked above in a somewhat shortened form) and then the recipe in question just looks like this.
posted by jessamyn at 7:32 AM on January 13, 2006

Could there be a problem with your $HOME definition?
posted by ursus_comiter at 7:44 AM on January 13, 2006

In other words, does the command 'echo $HOME' show you your home directory as it should be listed? Are you using $HOME successfully in any other parts of your .procmailrc?
posted by ursus_comiter at 7:52 AM on January 13, 2006

Alternatively, does it work if you hard-code the full paths in your INCLUDERC lines? As,


or wherever.
posted by nicwolff at 9:16 AM on January 13, 2006

for 2: i think you're trying to use the "de morgans law" trick to get OR from AND, but i'm not sure. see the explanation here - scroll down to the subsection titled "DeMorgan's Laws".
posted by andrew cooke at 10:06 AM on January 13, 2006

rats. http://perlcode.org/tutorials/procmail/proctut/proctip2.pod for my link above.
posted by andrew cooke at 10:07 AM on January 13, 2006

$HOME seems to be working corerctly elsewhere. I'll try including the full path in INCLUDERC and see if it does any good. Thanks much for the tips, debugging this is a total pain in the ass.
posted by jessamyn at 11:16 AM on January 13, 2006

followup: I never did get it working quite right, but I figured out some more syntax problems that I was having based on the AND information that ursus_comiter included which solved the immediate problem. Thanks everyone for pitching in.
posted by jessamyn at 1:43 PM on February 6, 2006

« Older PivotTableFilter   |   Graphics Website Newer »
This thread is closed to new comments.