Go to the console server Asterisk. First of all, create a file with the .sh extension in it, we put our script:
touch /var/lib/asterisk/bin/rectoemail.sh
We give the file the necessary rights and permissions:
chown asterisk: asterisk rectoemail.shchmod 774 rectoemail.sh
Now open the script file itself for editing:
vim /var/lib/asterisk/bin/rectoemail.sh
#!/bin/bash
dt=$(date '+%m/%d/%Y %r');
echo -e "שלום! יש שיחה חדשה במערכת \n\n
תאריך ושעה $dt \n\n
מקור השיחה - $5 \n\n
יעד השיחה - $7 \n\n
מצורף קובץ הקלטת שיחה \n\n" | mail -a /mnt/nfs/recstore/$1/$2/$3/$6 -s "הקלטת שיחה חדשה" mail@gmail.com
REFINING IN FREEPBX
Now you need to put our script to start automatically. Go to the section Settings → Advanced Settings . Make sure that the Display Readonly Settings and Override Readonly Settings parameters are set to Yes .
Now we find the Post Call Recording Script parameter and add the following line to its field:
bash /var/lib/asterisk/bin/rectoemail.sh ^{YEAR} ^{MONTH} ^{DAY} ^{TIMESTR} ^{FROMEXTEN} ^{CALLFILENAME}.^{MIXMON_FORMAT} ^{ARG3}
++++++++++++++
Let's run through the variables that will be related to the call and will be transmitted (all except $ dt) with Asterisk:
- $ 1 - the year of the call;
- $ 2 - month call;
- $ 3 - day call;
- $ 4 - date and time in string format;
- $ 5 - source of the call (caller);
- $ 6 - the name of the audio record of the conversation;
- $ 7 - where the call was made;
- $ dt - generate the date of the call;