Here is a script and awk file I wrote to allow our users to do some basic
functions
like delete their entire mailspool, or change their forwarding.
Mike Holloway
beta@???
(972) 4THENET (484-3638)
(817) 332-3092
http://www.ticnet.com
The Internet Connection
>What about the other option I described, i.e., enabling the users
to somehow put the .forward files on the mailserver?
>Vadik.
This script I named forward.sh, and made every pop3 user have this as a
shell (for my
installation, both these scripts are located in /home, "gawk" is in the
path - we are
also using /var/spool/mail/ for the mail files for the users, adjust if
necessary). Be sure
to chmod a+rx on these files :
##
## /home/forward.sh
##
USERNAME=`id -nu`
while :
do
MAILFILE="You currently have no mail on this system."
if [ -f /var/spool/mail/$USERNAME ]
then
MAILFILE=`ls -l /var/spool/mail/$USERNAME | gawk -f /home/forward.awk`
fi
if [ -f $HOME/.forward ]
then
CONTENTS=`cat $HOME/.forward`
echo "
Your mailbox is currently forwarded to :
$CONTENTS
$MAILFILE"
else
echo "
Your mailbox is not currently forwarded.
$MAILFILE"
fi
echo -n "
C - Change current mail forwarding
D - Delete all email from server
R - Remove mail forwarding
Q - Quit
Option :"
read ANS
case $ANS in
q|Q|x|X)
exit ;;
r|R) rm -f $HOME/.forward ;;
d|D)
echo -n "
Are you sure you want to delete all email (this action is not reversable) :"
read ANS2
case $ANS2 in
y|Y|yes|YES) rm -f /var/spool/mail/$USERNAME
esac
;;
c|C)
echo -n "
Please enter the email address(es) that you would like to forward your
email to. Don't put any spaces, and use a comma to separate addresses.
If you make a mistake, use only the DEL key to correct it, backspace
or your arrow keys will create hidden characters that cause the forward
not to work. If in doubt, delete all forwarding and retype it.
Example : johndoe@???,janedoe@???
Forward to :"
read ANS2
case $ANS2 in
"") ;;
*) echo $ANS2 > $HOME/.forward
esac
;;
esac
done
##
## end /home/forward.sh
----------------------------------------------------------------------
And for the /home/forward.awk file :
----------------------------------------------------------------------
BEGIN { }
{
printf("Mail size : %s Last message received : %s %s %s",$5,$6,$7,$8)
}
--
*** Exim information can be found at
http://www.exim.org/ ***