If anyone is interested, here are my mail scripts for getting and sorting mail.
/etc/fetchmail/fetchmailrc: (I have postmaster as an alias of philip)
set logfile "/var/log/fetchmail.log" set syslog set postmaster "postmaster" set bouncemail set properties "" set invisible set idfile "/etc/fetchmail/fetchids" set daemon 500
poll mail.vsnl.net with proto AUTO uidl: user tellis there, with password xxxxxxx, is philip here; options warnings 3600 dropstatus limit 1000000 fetchall
~philip/.procmailrc:
LOGFILE=.procmail.log #LOGABSTRACT=none VERBOSE=off
:0 *From: .*spammers and people I don't like /dev/null
:0 *From: .*(regex of my sister's friends) !mysister
:0 *To: .*regex that covers all my sister's names/nicknames !mysister
:0 *(To|Cc): .*regex that covers my all my sister's email addresses !mysister
:0 *To: .*regex that matches mails that both my sister and I must receive { :0 c !mysister
:0: mail/incoming/folder where I want this mail to go }
:1 Subject: .*Ilug-Bom Web Site - Updated mail/trash
:1: *To: .*linuxers mail/incoming/lug-incoming
:1: *From: .*Webmonkey mail/webmonkey
(and on and on)
/etc/ppp/ip-up.local:
[ $# -lt 1 ] && DEV="ppp0" || DEV=$1 # find out which interface pppd is connected to
MYIP=$(/sbin/ifconfig $DEV | grep "inet addr" | cut -f2 -d: | cut -f1 -d' ') # find out the IP of that interface
echo -e "$MYIP\ttellis.vsnl.net" >> /etc/hosts # add this IP to /etc/hosts so that sendmail doesn't cry when a # remote host tried to do a reverse lookup
[ "$(date | egrep -i '(sun)|((23)|(0[0-7])):..:..')" != "" ] \ && RCFILE="/etc/fetchmail/fetchmailrc" \ || RCFILE="/etc/fetchmail/fetchmailrc.day"
# Since I get free time between 11 and 8 and Sundays, I should # only download large mails at these times. Otherwise, use a # fetchmailrc that limits max mail size to 10K. This only makes # sense if the server supports IMAP otherwise, it is worse.
echo "fetchmail: using $RCFILE" >> /var/log/fetchmail.log # log what we're doing
fetchmail -f $RCFILE # and start fetchmail with the correct rc file. Fetchmail # should run as a daemon
/usr/sbin/sendmail -q # flush the mail queue. This does not run as a daemon
# I should also change the queue processing interval here and reset it # in ip-down.local
exit 0
/etc/ppp/ip-down.local:
HOSTS=$(head -n 2 /etc/hosts) echo -e "$HOSTS" > /etc/hosts # get rid of the extra host line added # in ip-up.local # this is risky, but in my case safe
exit 0
/etc/sysconfig/network-scripts/ifdown-ppp:
# These lines are inserted after signalling ifup-ppp not to persist if # it hasn't already started
# This will check if there are messages in the mailq # It will try to send them and wait until all are sent.
if [ $( mailq | wc -l ) -gt 1 ]; then echo "Waiting for mail queue to flush..." >&2 /usr/sbin/sendmail -q fi;
# First check if fetchmail is running. If it is, wait for it to stop # This will go crazy if fetchmail is running in daemon mode because # then it will not stop.
# If you have fetchmail running in daemon mode, you may want to comment # out the lines below and put fetchmail -q in /etc/ppp/ip-down.local
# You should check /var/run/fetchmail.pid to see the pollinterval. # Fetchmail should not be run as a daemon because we don't know what # state it currently is in
# if [ -f /var/run/fetchmail.pid ]; then # echo "Waiting for fetchmail to stop..." >&2 # else
# If fetchmail wasn't running, then run it one last time to get any mail # that may have come in after the last check
# echo "Checking mail before disconnecting..." >&2 # fetchmail -f /etc/fetchmail/fetchmailrc # echo "Done..." >&2 # fi;
# while [ -f /var/run/fetchmail.pid ]; do # this could potentially # /bin/true # wait forever and isn't # done # recommended
Furthermore, the following is added to the panel of users:
~user/.gnome/panel.d/default/Applet_9_Extern:
[mail] animation_file=/usr/share/pixmaps/mailcheck/email.png update_frequency=15000 exec_command= mail_prog_command=xterm -e /usr/bin/pine
This causes a mailchecker to run in the Gnome panel. When new mail comes in, the mail icon starts spinning. Clicking the icon brings up pine, but you can make it bring up netscape messenger or kmail too.
Hope this helps others,
Philip