#!/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 9fans@9fans.net
#
# % cat $home/lib/outgoing_aliases_from
# 9fans@9fans.net maht-9fans@maht0x0r.net
#
# echo 'Hi from maht' | mail -s 'Hello 9fans' 9fans
#
# will send 9fans@9fans.net the email from maht-9fans@maht0x0r.net
#
#
#
|