Subject: procmail help needed..

From: [email-masked] (Monte Freeman)
Date: Mon, 1 Aug 1994 04:41:24 -0400 (EDT)

Hello,

 I've recently started using the procmail package along with a program called
'tpage' to send parts of mail messages to alphanumeric pagers. So far, most of
it is working great. As more and more people around my office find out about
what my setup can do, I get more requests for more features... :-/

 The most recent request is for a 'return receipt with error checking'. I want
to send back a reply to the person who sent the message telling them that the
page request that they just sent was successful if they supplied a valid name,
AND I want to send them a message back saying that the request failed if they
did NOT specify a valid name.

 I've gotten the return message part to work using formail. What I can't seem
to figure out is how to send one reply if they sent a page request to a person
that I can contact through my software; but send a different reply if they tried
to page someone my software doesn't know about.

 Here's my .procmailrc with a few of the valid names removed to save some space
in this message:

---BEGIN INCLUDE---

MAILDIR=$HOME/Mail      # You'd better make sure it exists
DEFAULT=$MAILDIR/mbox
LOGFILE=$MAILDIR/from
LOCKFILE=$HOME/.lockmail

:0
* !^From +beep
* !^Subject:.*Re:
* !^FROM_DAEMON
* ^Subject:.*help
| (formail -r ; cat ~/tpage.help) | /usr/lib/sendmail -oi -t

:0 bc:
* ^Subject: *page monte
  |/usr/local/bin/tpage monte -

:0 bc:
* ^Subject: *page daveb
  |/usr/local/bin/tpage daveb -

:0 bc:
* ^Subject: *page jules
  |/usr/local/bin/tpage jules -

[several more recipies just like these deleted for brevity]

:0 bc:
* ^Subject: *page doug
  |/usr/local/bin/tpage doug -

:0  !E
* !^FROM_DAEMON
* !^From +Beeper
| (formail -b -k -r ;\
   echo "I don't know how to page the person specified in the subject of" ; \
   echo "your mail message. Please check to see if the name is spelled  " ; \
   echo "correctly, and that this person is pagable through this gateway." ; \
   echo "You can get a list of the people I know how to page by sending" ; \
   echo "me a message with the subject \"help\". If the name is spelled" ;\
   echo "correctly AND it's in the list, then please send a description of "; \
   echo "what you've done so far to [email-masked] so he can" ;\
   echo " look into the problem.") | /usr/lib/sendmail -t

:0  
* !^FROM_DAEMON
* !^From +Beeper
| (formail -b -k -r ;\
   echo "The above text has been sent to the pager owned by the person  " ; \
   echo "named in the subject of this message. Please check to see that  " ; \
   echo "the name is spelled correctly. If it is, then you're all set." ; \
   echo "If not, then you will need to send your message again. If you " ; \
   echo "need help, send me a message with the subject of \"help\" and I'll" ;\
   echo "send you a list of valid names.") | /usr/lib/sendmail -t

---END INCLUDE---

 Now, if I send a mail message to the account where this software lives, and
that message has the subject of "page monte", I want the page to be sent (the
body of the message to be picked out of the message and sent to tpage) AND I
want a reply to be generated that includes the text of the original message as
well as the text from the recipe "The above text has been sent...."
NOTE: I have this much working now. This part isn't the problem.

 If I send a mail message to the account where this software lives, and the
sujbect is "page fred" (or anything besides a valid name or the word help), then
I want a reply to be generated back to the sender that contains the message they
sent as well as the text from the recipe "I don't know how to page the person.."
This is the part I can't make work.

 I've tried multiple different combinations of the flags 'a', 'A', 'e', and 'E'
as well as using the '!' as a modifier. I haven't been able to find anything
that will do what I need here. Am I trying to do something that procmail and
formail aren't capable of doing or am I just doing it wrong?

 I apologize that this message got so long, but I didn't see any way to explain
my problem in a shorter message...

 Any help you can provide would be greatly appreciated!!

    Thanks,

-- 
Monte Freeman  --  Operations Department / Information Technology
Georgia Institute of Technology, Atlanta Georgia, 30332
Internet: [email-masked]
Bitnet:   [email-masked]

---

From: Roman Czyborra <[email-masked]>
Date: Mon, 1 Aug 1994 11:57:32 +0200

> telling them that the page request that they just sent was successful

For this you really ought to check tpage's exit code, or can't it fail?

> if they supplied a valid name,

That's even easier to test:

	OKAY="
Yep, I know that person.
Your message was beamed right over."

	SORRY="
Your request failed.
I don't know anybody with such a weird name."

	: # paging a known person
	* ^Subject: *page (monte|daveb|jules|jacques)
	| (formail -r ; echo "$OKAY" ) | $SENDMAIL -t

	:E # else: not to any known user, but trying to page somebody else
	* ^Subject: *page [a-z]
	| (formail -r ; echo "$SORRY" ) | $SENDMAIL -t

> am I just doing it wrong?

The condition for your okay message matched before the one for your
sorry message ever got a chance to.  Plus, the ! can't go with the
flags but only in the condition line (*) if you want to negate that.

You have procmail v3.03, don't you?  I'm asking because the E flag was
a fairly recent addition.