Question

first i already done with recording and save to '.wav' file and also im done with the script that email the '.wav' using 'postfix', my problem is when the recording is done automatically email the '.wav' file to my email e.g 'gmail',

What should i do?
should the script is indicate to extension.conf?
or should i need to a set a varables that the filename of .wav file will connect to my script?

here's the example script to my extesion.conf

[outbound]
exten => s,1,Answer()
exten => s,2,Background(silence/1)
exten => s,3,ControlPlayback(/var/example)
exten => s,4,Record(/var/${callfile_name}${STRFTIME(${EPOCH},GMT-8,%m%d%y-%H%M)}.wav,0,5,qxk)
exten => s,5,Hangup()

Here's the script that email to my gmail using 'postfix'

(printf "%s\n" \
"Subject: Example_Subject" \
"To: example_email@gmail.com" \
"Content-Type: application/wav" \
"Content-Disposition: attachment; filename=examplewav.wav" \
"Content-Transfer-Encoding: base64" \
""; base64 examplewav.wav) | sendmail "example_email@gmail.com"

Était-ce utile?

La solution

You could set the filename to a variable and execute sendmail on hangup, via the h extension.

[outbound]
exten => s,1,Answer()
exten => s,n,Background(silence/1)
exten => s,n,ControlPlayback(/var/example)
exten => s,n,Set(filename=${callfile_name}${STRFTIME(${EPOCH},GMT-8,%m%d%y-%H%M)}.wav)
exten => s,n,Record(/var/${filename},0,5,qxk)
exten => s,n,Hangup()
exten => h,1,System(/opt/scripts/wavmail.sh ${filename} example_email@gmail.com)

/opt/scripts/wavmail.sh (first argument is $1, second $2, ...)

#!/usr/bin/env bash

(printf "%s\n" \
"Subject: Example_Subject" \
"To: $2" \
"Content-Type: application/wav" \
"Content-Disposition: attachment; filename=$(basename $1)" \
"Content-Transfer-Encoding: base64" \
""; base64 $1) | /usr/bin/sendmail "$2"

Autres conseils

Recomended way: save in cdr info about where to send this file and send file using external daemon(using queue) if cdr have that field. That is most scalable way. easy way - see pce's answer.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top