In case anyone comes across this post I have extened teh script to convert the recording to mp3 before emailing it.
#!/bin/bash
#This script emails the recorded call right after the call is hung up. Below are the variables passed through asterisk
# $1 - Time String
# $2 - Source
# $3 - File
# $4 - unique id
# $5 - Destination
# $dt - Date and Time
/bin/nice /bin/sleep 3
dy=$(date '+%Y')
dm=$(date '+%m')
dd=$(date '+%d')
file_age=35
dtpath=/var/spool/asterisk/monitor/$dy/$dm/$dd/
/bin/nice /usr/local/bin/lame -b 16 -m m -q 9-resample $dtpath$3.wav $dtpath$3.mp3
/bin/nice /bin/chown asterisk:asterisk $dtpath/$3.mp3
dt=$(date '+%m/%d/%Y %r');
echo $dt
echo -e "You have a new call recording to listen to \n\n
The call date and time was $dt \n\n
The call was from $2 \n\n
The call was to $5 \n\n
And the unique call id was $4\n\n
Please see the attached file \n\n" | mail -a $dtpath$3.mp3 -s "New Call Recording" [email protected]
/bin/nice /usr/bin/find /var/spool/asterisk/monitor/ -type f -mtime +"$file_age" |grep wav | \
while read I; do
/bin/rm "$I"
done
The post record string in freepbx is as below
/usr/local/sbin/postrecord.sh ^{TIMESTR} ^{FROMEXTEN} ^{CALLFILENAME} ^{UNIQUEID} ^{ARG3}
Finally remember to set the masquerade in sendmail so that the email correctly addressed
Enjoy