#!/bin/rc
rfork e
# collect upas/send options
options=()
while (! ~ $#* 0 && ~ $1 -*) {
options=($options $1);
shift
}
dests=() # replace destination addresses
while (! ~ $#* 0) {
a=`{awk '$1=="'^$1^'" { print $2 } ' $home/lib/outgoing_aliases_to}
if(~ $#a 0)
dests=($dests $1);
if not
dests=($dests $a)
shift
}
if(~ $#dests 1)
cache = /dev/null
if not
cache = /tmp/cache
fn out {
while(r=`{read} && ! ~ $#r 0) {
if(~ $r From:*)
echo From: $upasname
if not
echo $r
}
cat
}
for(d in $dests) {
upasname=`{awk ' $1=="'^$d^'" { print $2 } ' $home/lib/outgoing_aliases_from}
if(~ $#upasname 0)
upasname=$user
if(test -s $cache) # format our copy
out < $cache | upas/send $options $d
if not # copy and format stdin
tee $cache | out | upas/send $options $d
}
rm -f $cache
###########
# Example
# % cat $home/lib/outgoing_aliases_to
# 9fans [email protected]
#
# % cat $home/lib/outgoing_aliases_from
# [email protected] [email protected]
#
# echo 'Hi from maht' | mail -s 'Hello 9fans' 9fans
#
# will send [email protected] the email from [email protected]
#
#
#
|