Hey List,
I am trying something that I'm being told isn't anywhere near practical
but I have this gut that tells me someone on this list does it.
I am trying out a situation where one uses Procmail as the LDA for Exim
(yes, that robust MTA). I am actually in the process of testing whether it
is possible to use a global procmailrc for switching on two things:
Allow clients with e-mail only access on this FreeBSD box to do the
following via a recipe (Louis-David Mitterrand, are you still around?):
1. Switch ON/OFF an autoresponder
2. Switch ON/OFF e-mail forwarding to another account.
What I am trying to do is to incorporate two recipes that were posted to
this list into a global procmailrc, which I need to put in
/usr/local/etc/.
Now I am really happy with procmail.
(although some people on this list would tear me to pieces if they were
to physically get hold of me because of a silly whitelist thing that
I use here. Sorry folks I'll refine my ways when I become of age with
procmail) It shouldn't happen when one replies to me or when the subject
line has 'procmail' on it though.
There is a hitch though: I've read from (man procmail) that it checks for
a global procmailrc then, $HOME/.procmailrc, right?
But I have to prod it to look at my $HOME/.procmailrc by having a .forward
file in my $HOME which says
"| /usr/local/bin/procmail"
I know everyone have their own way of doing that but here is where I am
stuck.
I don't want to have a /usr/share/skel/dot.forward and a dot.procmailrc
that would be copied to every new user's home directory when I add the
user. I think I'll be filling ny disk, no? If there is a way I'll
definately do with it. Some hand-holding here.
Those running Exim would be better placed to help me. I already have the
necessary transport/director with procmail that tells exim to use Procmail
(BTW is it procmail or Procmail?) as the LDA but Exim kinda requires that
every user have a .procmailrc. This can be circumvented, no?
Here is my Exim transport:
# Allow Procmail to be used for local deliveries
procmail_pipe:
driver = pipe
command = "/usr/local/bin/procmail -d $local_part"
return_path_add
delivery_date_add
envelope_to_add
freeze_exec_fail = false
log_defer_output = false
log_fail_output = false
log_output = false
return_fail_output = false
return_output = false
check_string = "From "
escape_string = ">From "
user = $local_part
# group = mail
umask = 0022
..and here is the Exim director
# Since order matters, let us process e-mail using Procmail first!
procmail:
driver = localuser
transport = procmail_pipe
That might not be all that Exim needs but I am hoping it should kinda work
because a test of exim -bt says the correct thing:
wash:~$ exim -bt wash
wash(_at_)test-domain
deliver to wash in domain test-domain
director = procmail, transport = procmail_pipe
Below is what Mitterrand wanted to test but I am now doing instead (call
me a copy cat but sometimes it's a way of life - a necessary evil;-))
##
# From: Louis-David Mitterrand <vindex(_at_)apartia(_dot_)ch>
# Aug 13, 2001 at 05:41:29PM +0200
# company-wide vacation system based on procmail
# A client liked so much the little vacation recipe I installed for him
# that all his co-workers want to be able to edit, activate, disable their
# own vacation reply. That is without ever thouching a procmail recipe of
# course.
#
# Here is a first try at a vacation implementation for non-unix users.
#
# To activate her vacation message a user simply sends herself a message
# containing the vacation auto-reply with a subject of "vacation on".
#
# To cancel her auto-reply the user sends herselft a "vacation off"
# message.
#
# In /etc/procmailrc:
#
LOGFILE=/tmp/procmail.log_`/bin/date +%y-%m-%d`
VERBOSE=on
XLOOP=$LOGNAME(_at_)$HOST
VAC_MESSAGE=$HOME/.vacation.msg
VAC_CACHE=$HOME/.vacation.cache
VAC_LOCK=$HOME/.vacation.lock
NL=""
# test if message is to and from the same address and if suject is
# "vacation on" or "vacation off"
:0
# adressed to a system user
*$ ^TO_$LOGNAME@
# and is from that same user
*$ ^From:.*$LOGNAME@
# has subject containing only "vacation (on|off)"
* ^Subject: *vacation *\/o(ff|n) *$
# clean out extra space
* MATCH ?? ()\/o(ff|n)
{
ACTION=$MATCH
LOG="ACTION: $ACTION, USER: $LOGNAME, HOME: $HOME $NL"
:0c
* ACTION ?? off
# remove vacation message and cache
| rm $VAC_MESSAGE $VAC_CACHE
:0Ebc
# create vacation message from body
| cat > $VAC_MESSAGE
# FIXME: extra newline in output; how to deal with attachements?
# As confirmation that vacation works the user will receive his own
# auto-reply from the next recipe
}
:0
# is there a vacation message for that user?
*$? "test -e $VAC_MESSAGE"
{
# from procmailex
:0 Whc: $VAC_LOCK
# Perform a quick check to see if the mail was addressed (to|cc) us
*$ ^TO_$\LOGNAME@
# Don't reply to daemons and mailinglists
* !^FROM_DAEMON
# Mail loops are evil
*$ !^X-Loop: $XLOOP
| formail -rD 8192 $VAC_CACHE
# if the name was not in the cache
:0 ehc
| (formail -rI"Precedence: junk" -A"X-Loop: $XLOOP" ; \
cat $VAC_MESSAGE ) | $SENDMAIL -oi -t
}
############################
That upper portion, as you can see is the one that switches
(supposedly) the autoresp ON/OFF
..and here is what was on this list since 2 days ago, that supposedly
switches the forwarding ON/OFF
NB: It is still incomplete and is supposed to be modified so that it
becomes capable of creating/deleting a file called .forward in the user's
home to switch ON/OFF forwarding. The .forward normally is supposed to be
a file containing a single line with an e-mail address.
##
:0bi:
* $ ^From: $LOGNAME
* ^Subject: mailforward-on
| sed -ne/^$/q -ep >> /home/$LOGNAME/.forward
The first line in the body of the message should have the alternate e-mail
address, correct?
The biggest problem I see on implementing this on my system is that a
/home/$LOGNAME/.forward is supposed to be used to forward mails to another
account elsewhere. How then do I handle the _combination_
forwarding/autoresponder? How do I tell procmail to help me in those two
issues? I am a lazy sysadmin and would prefer to only sit and eat and let
things happen nicely ;-)
The best I've ever done on my own is just write maybe upto 10 lines of a
shell script (and it wouldn't be such an advanced one for that matter) so I
would appreciate all HELP and modifications that can be applied to get
this thing working.
I must thank you for having read upto this far. It means you've the heart
of an elephant and might just give the help.
-Wash
--
Odhiambo Washington
Wananchi Online Ltd.,
wash(_at_)wananchi(_dot_)com 1st Flr Loita Hse.
Tel: 254 2 313985 Loita Street.,
Fax: 254 2 313922 PO Box 10286,00100-NAIROBI,KE.
The colder the X-Ray table, the more of your body is required on it.
pgp1QyOzIR8z5.pgp
Description: PGP signature