1. Home
  2. Computing & Technology
  3. Linux

From Authors, for About.com

/etc/sysconfig/network-scripts/ifup-post (this script is run, whenever a network device is started)


   

# Notify programs that have requested notification
do_netreport
# BEGIN new stuff
# check for email -- I'm using fetchmail for this
if [ "${DEVICE}" = "eth0" -o "${DEVICE}"
= "ppp0" ]; then
su -lc fetchmail myusername >& /dev/null &
fi
# set clock if connected to ethernet, redirect email
if [ "${DEVICE}" = "eth0" -a "'hostname'" = "zaphod" ]; then
( rdate -s server1 ; hwclock --systohc --utc ) >& /dev/null &
# forward email
su -lc "ssh -l myusername gradj utl/forward_laptop" myusername >& /dev/null &
fi
# END new stuff

exit 0

15.3.1.5. Processing Incoming E-Mail with procmail

This step is completely optional. The above described sendmail configuration calls procmail for each received email, but you could have called procmail using the .forward file (see the procmail man page). Procmail is a handy tool to block spam and to sort incoming email.

You need to setup a .procmailrc file to use procmail . See the man page for procmail, procmailrc, and procmailex (examples). My setup demonstrates, how to ignore certain email messages and split email-collections (digest) into pieces:


   

# -- mail filtering -- procmail is called by sendmail --
PATH=/bin:/usr/bin
MAILDIR=$HOME/Mail
LOGFILE=$MAILDIR/from
# keep in mind:
# use ":0:" when writing to a file
# use ":0" when writing to a device, e.g. /dev/null, or send email

# - make a backup of *all* incoming mail, but ignore mail tagged below -
:0 c:
*! ^Sissa-Repro
backup

# - keep only last 50 messages
:0 ic
| cd backup && rm -f dummy 'ls -t msg.* | sed -e 1,50d'

# - delete email coming through the 'postdocs' email list, when
# it is not of any interest
:0
* ^From.*postdocs
* ^From.*Ernst Richter /dev/null :0
* ^From.*postdocs
* ^Subject.*card charge
/dev/null
# Split mailing list from the sissa preprint server into individual emails
# - this is quite complicated :( I can flip through the list much
# faster and ignore preprints which have uninteresting titles. Instead of
# having to browse through the whole list, my mailer will just present a
# list of papers.
# 1. split it in individual messages
:0
* ^From no-reply@xxx.lanl.gov
| formail +1 -de -A "Sissa-Repro: true" -s procmail
# 2. reformat messages a bit
# 2.1. extract 'Title:' from email-Body and add to email-header
as 'Subject:'
:0 b
* ^Sissa-Repro
*! ^Subject
TITLE=| formail -xTitle:
:0 a
|formail -A "Subject: $TITLE " -s procmail

# 2.2. store in my incoming sissa-email folder. Here, we could
# also reject (and thereafter delete) uninteresting 'Subjects'
# we could also mark more interesting subjects as urgend or send a copy
# to regular mail box.
:0:
* ^Sissa-Repro
* ^Subject
*! ^replaced with
sissa

By the way, there is a tk GUI tool to configure procmail (I think it is called dotfiles ).

Explore Linux

More from About.com

  1. Home
  2. Computing & Technology
  3. Linux

©2008 About.com, a part of The New York Times Company.

All rights reserved.