Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Given the following procmail recipe:

:0:
* ^Subject:.*viagra.*
* ^From:.*viagra.*
/dev/null

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.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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.

:0: 
* ^(From|Cc|To|Subject).*viagara.* 
/dev/null

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.

:0:
* ^Subject:.*viagra.* |\
  ^From:.*viagra.*
/dev/null
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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