[comp.unix.wizards] Help with sendmail.cf

brad@bradley.UUCP (11/20/87)

I have a need to make a site look like a uucp site (via mail) but
not really be.  What I want is all mail sent to 'XXX!user' to be
sent to a file or pipe to a program.  How would one set up
sendmail.cf so it can to it?  Do I need to hack sendmail to say
anytime you get this machine do something other than send it
to uux/rmail/smail?


Bradley Smith			UUCP: {cepu,ihnp4,noao,uiucdcs}!bradley!brad
Text Processing			ARPA: cepu!bradley!brad@CS.UCLA
Bradley University		PH: (309) 677-2337
Peoria, IL 61625

kai@uicsrd.csrd.uiuc.edu (11/23/87)

Simple if you are running 4.[23] BSD.  I can't help you if you've got any
other flavor.  Setup an alias in /usr/lib/aliases to feed the mail through
a pipe to a program.  Try:

bugfile:"| cat >> /usr/local/lib/bugfile"
bugfile:"| mail_filter"

Which just feeds the mail msg through a pipe to the "cat" pgm.  Add the
above line (double quotes are neccessary) to /usr/lib/aliases and execute
the "newaliases" command.  If you see messages about the database files not
existing previously, execute newaliases again.

The above alias is flawed, of course, because without using some method of
file locking, two mail messages delivered at the same time to
"host!bugfile" may cause trash to appear in the file.  I worked around that
by writing a simple "cat"-like pgm that uses FLOCK to ensure exclusive
access.

If you want to peruse the file using Mail, you will have to make sure that
an empty line appears before each mail message.  Mail seems to expect
"<CR>From <address> <date><CR>" to appear at the beginning of each mail
message, otherwise you appear to have one HUGE msg.

It is also possible for individuals to write their own personal mail
filter.  Setup a .forward file in your home directory that contains a
similar pipe.  For example:

"| /homes/pwolfe/bin/mail_filter"

does what you might expect it to.  Useful applications can be written for
this, a better "biff", separating mail heading for group accounts, vacation
notification replies, etc.  Beware!!  You alone are responsible for any
messages lost due to a faulty mail filter!!

Hope this helps.


Patrick Wolfe

Internet:  pwolfe@kai.com
UUCP:      ...!{uunet,ihnp4}!uiucuxc!kailand!pwolfe