###########################################################
# This is a file of commands that is sourced when
# new mail is received.
#
# The intent was originally to do regular-expression matching
# on the lastFrom and lastSubject variables to customize phimail's
# response to new mail from different people and with different
# subjects.
#
# You have the lastFrom and lastSubject variables
# to work with.  You may want to echo them
# if your regular expressions aren't working properly.
#
# You can define your own variables, if you need.  Just avoid
# stepping on any variables used by phimail itself.
#
# For more information on the regexp command of Tcl, do a
# 'man regexp'.  You should get all the info you need, assuming
# your system is set up correctly.
###########################################################

# echo variables for debugging
#puts $lastFrom
#puts $lastSubject

###########################################################
# some regular expression matching examples
###########################################################

# here's a good one for playing a custom sound
# file for the from person
set personFrom ""
if {[regexp (\[a-zA-Z\])(@) $lastFrom match personFrom]
    || [regexp (\[a-zA-Z\]*) $lastFrom match personFrom]} {
#   puts "message received from '$personFrom'"
  if {[file exists $personFrom.au]} {exec cat $personFrom.au > /dev/audio}
}

# the most basic match for the person who sent the message
if {[regexp (.*my_friends_name.*) $lastFrom]} {
#   puts "message received from my_friends_name
   exec cat my_friends_name.au > /dev/audio
}

# a special alert for messages marked 'urgent'
if {[regexp -nocase (.*urgent.*) $lastSubject]} {
#   puts "urgent message!!!"
   exec cat alert.au > /dev/audio
}

# a message for all messages from a specific domain
if {[regexp (.*.caltech..*) $lastFrom]} {
#   puts "message received from caltech"
   exec cat caltech.au > /dev/audio
#   exec rsh some_machine "cat caltech.au > /dev/audio"
}
