[SOLVED] How To Email Call Recordings Post Call Recording Script

I have figured out how to successfully figured out how to email call recordings, and there wasn’t a guide so I wanted to make one for anyone else who is trying to email their call recordings.

Here is my bash script for emailing out the call recording that includes who called, and the number that was called, as well as the date and time of the call.

#!/bin/bash
#This script emails the recorded call right after the call is hung up. Below are    the variables passed through asterisk
# $1 - year
# $2 - month
# $3 - day
# $4 - Time String
# $5 - Source
# $6 - File
# $7 - Destination
# $dt - Date and Time


dt=$(date '+%m/%d/%Y %r');


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 $5 \n\n
 The call was to $7 \n\n
 
 Please see the attached file \n\n" | mail -a /var/spool/asterisk/monitor/$1/$2/$3/$6 -s "New Call Recording" [email protected]

Save that file in /var/lib/asterisk/bin I saved it as emailrecording.sh

cd /var/lib/asterisk/bin
chown asterisk:asterisk emailrecording.sh
chmod 774 emailrecording.sh

Then go into the FreePBX Web UI → Advanced Settings

Be sure to mark Display Readonly Settings as True and then mark Override Readonly Settings as True so you can change what needs to be changed.

Scroll down to Post Call Recording Script

Now comes the tricky part, it took me a little trial and error to get the variables to pass through correctly

bash /var/lib/asterisk/bin/emailrecording.sh ^{YEAR} ^{MONTH} ^{DAY} ^{TIMESTR} ^{FROMEXTEN} ^{CALLFILENAME}.^{MIXMON_FORMAT} ^{ARG3}

There is a space in between the } and ^ however in between the ^{CALLFILENAME} and ^{MIXMON_FORMAT} there is a period so it will be passed as filename.fmt so in my example it would be callfilename.wav

Once you have that added, go ahead an make sure call recording is enabled on one of your routes and test it out.

Below is what the email should look like (I have Zimbra)

Hopefully this guide was able to help you, if you have any questions please ask me.

2 Likes