I want to write a script to filter the coming E-mail.
People may send me mail simultaneouslly, I have to use the lock function.
The following is the script which is executed by changing .forward:
lockfile process_mail/temp_mail.lock
cat > process_mail/temp_mail
grep -i "cis294j" process_mail/temp_mail | cat >process_mail/goodmail
if (test -s process_mail/goodmail) then
cat process_mail/temp_mail >> process_mail/cis294j
else
cat process_mail/temp_mail >> process_mail/gcao
fi
rm -f process_mail/temp_mail.lock
I tested it by sending 40 mails at the same time, it loses two or three
mails. I don't know what's wrong with the lockfile.
Failing to solve the problem, I want to use procmail.
The following is part of my procmailrc:
(/usr/lib/sendmail is also $SENDMAIL)
:0 h c
* ^Subject.*cis294
| (formail -r -A"Precedence: junk";\
echo "Mail received.") | /usr/lib/sendmail -t
:0 A
cis294
By this, it should auto-reply to the sender, and save a
copy to cis294. I can find the coming mail in cis294,
but it did not send reply message.
Thanks,
--Guohong