From Juan Cuervo on Mon, 14 Dec 1998
Hello Answerguy, My name is Juan Cuervo and I was wondering if you could help me with this:
I need all the incoming mail of my mail server users to be send to their mailboxes (as usual), but also to be processed by an external program (I mean , not a MTA). So, I need so send a copy of the mail to this external program if the mail user has a file in their home directory (called, lets say, ~/.myprog ) wich indicates that the mail messages for that user should be parsed by this external program too.
Thank you for your help.
You can create an '/etc/procmailrc' and define 'procmail' as your local delivery agent. This is the most straightforward way to do this. However, it is pretty dangerous (the called program will be called as 'root') and it might result in unacceptable levels of overhead (depending on your number of users and their mail volumes).
In any event the contents of /etc/procmailrc would look something like:
:0c | /root/bin/mailfilter/.myprog
.... to send a copy of each mail item through a program as you described.
Personally, I don't recommend this, as it sounds like several disasters just begging to happen. However, you're welcome to experiment with this on a test system for a little bit to learn how it works.
Many Linux distributions include 'sendmail' configured to use 'procmail' as their LDA by default. Look for a group of lines in your /etc/sendmail.cf that looks like:
Mlocal, P=/usr/bin/procmail, F=lsDFMAw5:/|@qSPfhn9, S=10/30, R=20/40, T=DNS/RFC822/X-Unix, A=procmail -Y -a $h -d $u
... to see if this is the case. If not, either replace the Mlocal clause that's in your /etc/sendmail.cf (yuck!), or add an entry like:
... to your ".mc" (M4 configuration file) and regenerate your .cf file with the appropriate m4 command like:
m4 < foo.mc > /etc/sendmail.cf
Note that sendmail involves quite a bit more than this --- so you may want to get more detailed advice before trying this on a production mail server. There's a 900 page book from O'Reilly that's probably the best reference to 'sendmail' available. Arguments that we should also switch to 'qmail' or Wietse Venema's 'PostFix' (formerly known as 'Vmailer') may not help in your case.