[comp.mail.mh] Checking if recipient is on To: or Cc: list

sean@dmr.asa.com (Sean Baker) (05/31/91)

Does anyone know of a good way to tell whether the recipient
of a message is on the To: or Cc: list of the message?

I'm trying to do some maildelivery stuff, and I have a
function that I'd like to perform only if the recipient is
in the To: list of addresses.  I've tried passing the
maildelivery variable $(address) to my program, but this
variable always expands to the user name, not the actual
address in the To: or Cc: line.  If the $(address) expanded
to the actual address in the message text, I could just grep
for that in the To: and Cc: lines to see which one it was
contained in.

With aliasing and all, this is seeming more and more to be
nearly impossible to do reliably.  Or, perhaps (hopefully),
I'm just missing something.

Any help would be greatly appreciated.  If I have not made
myself clear as to what I'm asking, please let me know and
I'll try to clarify.

Thanks,

Sean.
=======================================
Sean Baker <sean@dmr.asa.com>
Data Management Resources
20725 South Western Avenue, Suite 100
Torrance, CA 90501
USA
(213)618-9677

sean@dmr.asa.com (Sean Baker) (06/01/91)

    Sean,
    
    In your letter dated Thu, 30 May 91 12:58:14 PDT, you wrote:
    >I'm trying to do some maildelivery stuff, and I have a
    >function that I'd like to perform only if the recipient is
    >in the To: list of addresses.
    
    So why not use
    
    To	foo			file	?	mail/foo
    
    >If I have not made myself clear as to what I'm asking, please let me know
    >and I'll try to clarify.
    
    Please do.  Regards, Neil.

Neil,

In a way, this would work.  But, ideally, this is what I
would like to do:

Have an entry in the .maildelivery file that says:

	X-Testheader "doprogram" pipe R "program"

So, if a message comes in with the following header:

	X-Testheader: doprogram nocc

The program would run, parse the X-Testheader body, and find
the "nocc" directive.  The program would then figure out if
the user is in the To: or Cc: list.  In this case, if the
user is on the To: list, no problem.  If the user is on the
Cc: list, the program would exit.

If the header were this:

	X-Testheader: doprogram cc

and the user is on the Cc: list, the program would run
normally.  In other words, I'd be sending this message out
to many users, but I want to be able to say "run this
program for the people on the To: list only", or, "run this
program for every recipient."

So, the question is, is there a reliable way for
the program to figure out if the user is on the To: or Cc:
list?  So far, I'm inclined to say no, simply because the
actual address text in the To: and Cc: lines could be almost
anything.  E.g., I get messages where my address is: 

	Sean Baker <S-Baker@DMR.ASA.COM>
	S-Baker@DMR.ASA.COM
	S-Baker <sean@DMR.ASA.COM>
	sean@DMR.ASA.COM
	Sean M. Baker <sean@DMR.ASA.COM>
	smb@DMR.ASA.COM

All of which are accepted because of aliasing (I'm using
MMDF as the MTA, by the way).  From the looks of these
addresses, there doesn't seem to be a reliable way to do
what I want to do.

However, I think I may be able to use your example to get
the job done, by using the following:

	To  foo  pipe  R  "program to"
	Cc  foo  pipe  R  "program cc"

And then let the program check the X-Testheader: header for
the "doprogram" directive.  The only problem with this is
that I'd be piping every message I receive into the program.

Any other suggestions or comments are welcome.

Thanks for your help,

Sean.

mchinni@PICA.ARMY.MIL ("Michael J. Chinni, SMCAR-CCS-W") (06/01/91)

Sean,

	Why not do something like the following:
To	recipientname	pipe	A	yourprogram to
Cc	recipientname	pipe	A	yourprogram cc

Your program would then check the value of argv[1] to see if it was "to" or
"cc" and act accordingly.

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
			    Michael J. Chinni
	 US Army Armament Research, Development, and Engineering Center
                       Picatinny Arsenal, New Jersey  
     ARPA: mchinni@pica.army.mil     UUCP: ...!uunet!pica.army.mil!mchinni
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

ziegast@UUNET.UU.NET (Eric Ziegast) (06/01/91)

"Michael J. Chinni, SMCAR-CCS-W" writes:
> 	Why not do something like the following:
> To	recipientname	pipe	A	yourprogram to
> Cc	recipientname	pipe	A	yourprogram cc
> 
> Your program would then check the value of argv[1] to see if it was "to" or
> "cc" and act accordingly.

Let's not forget Apparently-to:

There is probably a better way than having to check addresses.
For a list program I used, I had the users put ID/password combinations
on the Subject lines.  Not only is it esier to deal with, it provides
a rudimentary level of security.  Anyone can fake a From.  It's much harder
to get a password.  Just a thought.
--
Eric W. Ziegast - jr uunet postmaster - ziegast@uunet.uu.net