Article View: comp.mail.misc
Article #4027Re: Restrict mailing to specific people only?
From: John Chambers
Date: Tue, 13 Jan 1987 15:52
Date: Tue, 13 Jan 1987 15:52
62 lines
3145 bytes
3145 bytes
> We would like to be able to have a file for each user, which specifies
> the names/aliases to which they are allowed to send mail.
>
> Is this possible? Has anyone done it?
>
Well, I've done something rather similar, so what you want oughta
be easy, too. What I did was actually an interface between uucp
mail and a local in-house mailer, which I'll call foomail. The
puzzle in this case, of course, is not how to restrict the mail
to certain recipients; I wanted to maximize the list of recipients.
But the technique does both equally well.
Incoming uucp mail is handled by executing a program called 'rmail',
which is normally linked to 'mail', both in /bin. To extend the
mailer, you just unlink /bin/rmail, and replace it with your own
script. If you want to intercept outgoing mail, move /bin/mail
somewhere secret, and put your script in with both names.
This script will be called with $1 containing the mailpath, and
the message on standard input. It is easy to write a series of
tests:
if [ sometest $1 ]
then somemailer $1
if [ $? -eq 0 ]
then exit 0
fi
fi
repeated for as many different tests as you like. For instance,
you can invoke a test program that looks the recipient up in a
database. You can also make a copy of the message:
cat >>/tmp/msg$$
and pass its name to your test program. This lets you examine
it to determine the sender, or make tests on the subject matter,
or scan it for keywords, etc. [This is what the CIA and NSA do
to anything you mail outside the country. :-] Just remember to
delete the scratch file when you're done.
One thing I did that has come in very handy is to have a special
mail-forwarding directory $F that may contain executables. My
rmail script then sets $R to the recipient and does:
if [ -x $F/$R ]
then echo "There is a forwarding script for '"$R"'."
if $F/$R $R /tmp/msg$$
then echo "Delivered by '"$F/$R $R"'."
continue
fi
echo "Failure by '"$F/$R $R"'."
date
stat = 1
continue
fi
Users can then send mail to the mail-handling script as if it were
an ordinary user, and the script will process the message.
This should give you lots of ideas about how to impose your own
processing on mail. Try it; it's easy!
--
John M Chambers Phone: 617/364-2000x7304
Email: ...{adelie,bu-cs,harvax,inmet,mcsbos,mit-eddie,mot[bos]}!cdx39!{jc,news,root,usenet,uucp}
Smail: Codex Corporation; Mailstop C1-30; 20 Cabot Blvd; Mansfield MA 02048-1193
Clever-Saying: If we can't fix it, it ain't broke.
Technical Details
Message-ID:
<603@cdx39.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!cmcl2!yale!husc6!necntc!adelie!cdx39!jcReferences:
<2865@osu-eddie.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!cmcl2!yale!husc6!necntc!adelie!cdx39!jc From: jc@cdx39.UUCP (John Chambers) Newsgroups: comp.mail.misc Subject: Re: Restrict mailing to specific people only? Message-ID: <603@cdx39.UUCP> Date: Tue, 13-Jan-87 10:52:13 EST Article-I.D.: cdx39.603 Posted: Tue Jan 13 10:52:13 1987 Date-Received: Wed, 14-Jan-87 22:36:27 EST References: <2865@osu-eddie.UUCP> Distribution: na Organization: Codex Corp, a division of Motorola; Canton, MA, USA Lines: 62 Summary: It's easy, I think...