简体   繁体   中英

procmailrc recipe to match multiple recipients

I have a .procmailrc which matches To and do some shell execution.

VERBOSE=ON
MAILDIR=$HOME/mail
PMDIR=$HOME/.procmail
DEFAULT=/var/spool/mail/www
LOGFILE=$PMDIR/log

:0:
* To: \/.*example.com$
| process_new_mail.sh

The problem is when I send a mail with multiple recipients, it process twice and process_new_mail.sh gets called twice.

For example, when I send a mail to both joe@test.example.com and doo@test.example.com, I want to check whether To is ending with *.example.com and run process_new_mail and skip the subsequent To address recipients.

There is nothing in your recipe which would cause the action to be performed twice. If you receive two copies of the message, there will be two invocations, obviously.

Your question sounds like the age-old FAQ about Bcc; see http://www.iki.fi/era/procmail/mini-faq.html#bcc-explanation -- in so many words, if you are trying to match a regex on the headers in order to find out who the recipient is, you are doing it wrong. (Read the linked document section at least up through the Jane vs. Jill example.)

Incidentally, your recipe also has the locking problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM