Given the following procmail recipe:

* ^Subject:.*viagra.*
* ^From:.*viagra.*

Procmail would only delete emails that were both from viagra, and had viagra in the subject. Is it possible to apply the filter if either of the matches are true?

The solution should preferably not make use of the regular expression (regex1|regex2) operation, but if that is the only solution, then please say so.


You are close. A strong understanding of regex goes a long way toward successful procmail recipes. Procmail is extremely flexible, but that flexibility depends largely on regex.

* ^(From|Cc|To|Subject).*viagara.* 

Alternately, and I believe closer to what you want to achieve, use a pipe and new line escape to continue the rule on the next line (for readability). In your example, you were creating a new condition that also had to be matched.

* ^Subject:.*viagra.* |\

Just use two recipes, each going to /dev/null, one matching on Subject, the other matching on From. The first match wins. This is essentially the same as an OR operator. The reg1|reg2 approach would work, but I think it reads more clearly as two recipes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.