Hey guys, the following script sends an email when there is a missed call. Now I need to add a new functionality. As we have 5 different trunks, I have to extend the script in such a way that the name of the trunk through which an incoming call has been placed is also written in the email. Can you help me? Thanks in advance!
[code][user@domain agi-bin]# vi processCallEmail.sh
EMAIL=$1
CALLERIDNUM=$2
CALLERIDNAME=$3
DIALSTATUS=$4
VMSTATUS=$5
Extension=$6
LOGFILE="/var/log/asterisk/mail-notify/processCallEmail.log"
MAILCMD="mailx -s"
SUBJECT="Missed call from $3 (phone $2)"
SENDMAIL=1 #Set to 1 if you want it to email the alert. 0 is useful for debugging.
DEBUG=1 #Set to 0 for standard operation. 1 will log inputs and mail commands for debugging.
replase extensions from GSM slots
if [ $Extension -eq 1111111111111 ]; then
Extension="Slot_1"
fi
if [ $Extension -eq 2222222222222 ]; then
Extension="Slot_2"
fi
if [ $Extension -eq 3333333333333 ]; then
Extension="Slot_3"
fi
if [ $Extension -eq 4444444444444 ]; then
Extension="Slot_4"
fi
#log mail command
if [ $DEBUG -eq 1 ]; then
echo $1 $2 “${3}” $4 $5 >> $LOGFILE
fi
#Check we have an email address if not quit
if [ “$EMAIL” == “” ]; then
exit 0
fi
#log mail command
if [ $DEBUG -eq 1 ]; then
echo $BODY $MAILCMD $SUBJECT $EMAIL - date +%A
date +%D
date +%R
. status $DIALSTATUS. Dialed number $Extension. >> $LOGFILE
fi
BODY=“You missed a call from $CALLERIDNAME ($CALLERIDNUM) at date +%A
date +%D
date +%R
. (status $DIALSTATUS). Dialed number $Extension.”
#send email
if [ $SENDMAIL -eq 1 ]; then
echo $BODY | $MAILCMD "$SUBJECT" $EMAIL
fi
exit 0
[/code]