Email Notification for all recieved calls to a ring group/extension

We would like to be able to have all phone calls that are routed to a specific extension or ring group to have an email notification go out to those responsible for those extension/ring groups. The use case is we had Ring Central in the past, and it did email notification with all recieved calls. Our support group wants this funcionality back. Basically when a support call comes in, an email should go out regardless if it was answered, went to voicemail or a hang up. What I was thinking was to have an email script called, so that the following can be sent:
CID Name
CID Number

I saw there was some working going to be put into 2.10, the went to unknown for missed call module. Any help would be appreciated.

Today I am working on the same request and I have made some headway, even though I am not fully happy with the solution yet.

Here is how I have been able to get it to work:

  • Create a shell script which actually sends e-mail and placed it in
    /var/lib/asterisk/bin - called

  • Added a line to the “override” dial plan:
    exten => s,n,System(${ASTVARLIBDIR}/bin/ [email protected] “${STRFTIME(,%c)}” “${CALLERID(name)} ${CALLERID(num)}” “${EXTEN}” “${EPOCH}”)

this line is calling the script which then sends an e-mail.

The part I am not happy about yet is that I had to use the “extensions_override_freepbx.conf” to make this work. I will post once I find a better solution.

Here is the listing for the shell script:
#$1 email address
#$2 time
#$3 CallerID
#$4 CallLine
echo “FROM: [email protected]” >> $TMPFILE
echo "TO: "$1 >> $TMPFILE
echo "Subject: New call for “$4” recieved " >> $TMPFILE
echo ""
echo “Just wanted to let you know, you received a new call on Line “$4” at “$2”, from “$3”.” >> $TMPFILE
echo “” >> $TMPFILE
echo “Thank you” >> $TMPFILE
echo “” >> $TMPFILE
echo “.” >> $TMPFILE
/usr/sbin/sendmail $1 < $TMPFILE

Maybe a better solution is to create an extension in extension_custom.conf

exten => 399,1,System(${ASTVARLIBDIR}/bin/ [email protected] "${STRFTIME(,,%c)}" "${CALLERID(name)} ${CALLERID(num)}" "${EXTEN}" "${EPOCH}")

In the above case the extension 399 is a free usable extension number.
to test if this extension works just dial it from a phone.

When it works, add this extension just as any other to the ring group, when the ring group is called so will this extension.

Hope this works.



Your solution is almost there. However when the ring group is dialed Asterisk throws the following error:
dialparties.agi: EXTENSION_STATE: 4 (UNKNOWN)
dialparties.agi: Extension 65 has ExtensionState: 4

(65 is the free extension I used in your example).



MMM, i must say this i a tad bit unexpected.

But while thinking of it i think that a device hint might solve this.

So continuing on my own example try this :

exten => 399,1,System(${ASTVARLIBDIR}/bin/ [email protected] "${STRFTIME(,,%c)}" "${CALLERID(name)} ${CALLERID(num)}" "${EXTEN}" "${EPOCH}")
exten => 339,hint,Custom:EMAIL399

I do hope this helpt, i have not tested this :wink:


Would we be able to add it to the dialplan of the ring group perhaps by adding it to the extension_overrides.conf file? If so how would I go about doing that. I see tadpole is using s,n how do I only have it work for say ring group with extension number 9999?
Would it be
exten => 9999,n,System(${ASTVARLIBDIR}/bin/ [email protected] “${STRFTIME(,%c)}” “${CALLERID(name)} ${CALLERID(num)}” “${EXTEN}” “${EPOCH}”)?
I don’t want the script to run with every phone call. If it needs to run with every call then I could put a conditional in that would look for the inbound number…
Unfortunately, the hint didn’t help… Any other ideas?

Always refrain from using the override file, will safe al lot of headaces when upgrading.

it seems that i took the long way aproace and i think i have a solution.
Create the folowing dialplan

exten => s,1,System(${ASTVARLIBDIR}/bin/ [email protected] "${STRFTIME(,,%c)}" "${CALLERID(name)} ${CALLERID(num)}" "${EXTEN}" "${EPOCH}")
 same => n,Dial(Local/[email protected],300,tr)

In the above in the Local/[email protected] the 601 is you ringgroup.
Than in the GUI go to Tools, Custom Destinations -> Add

Custom Destination: custom-send-email-alert]
Destination Quick Pick :
Description: Send email alert 	
Notes: Sedns an Alert by email

Now you can use this as a destination in things like inbound routes.
Or you could assign it an feature code or Extension number using the Misc Applications.


That did the trick.
I would like to know if there is a way to add dialed number information. Right now it gives the “s” as their a way to give the DID that it recieves.
Also for a quick hint, I am sure I can search the web for it, I would like it to play a mp3 file instead of the ringing tone while the ring group is being called.

Thanks Again!


Yes, the EXTEN var gives the current executing extension number in return, FreePBX save the incoming DID in the FROM_DID variable.

Playing and external sound file depends on the phones used, but i doubt you’ll be able to play MP3 files, i think you should check the alert-info SIP header of your phone, some phones support the URL for the dowload location of a wav file to use as ring tone.

a sample Alert-Info is like.

exten => s,n,SIPAddHeader("Alert-Info:<>\;info=alert-external\;x-line-id=0")

Good luck.


Everything is working. I wasn’t very clear about how I wanted the mp3 to play. I wanted it to be the ring back for the caller. I found that in the Dial command there is an argument m.

same => n,Dial(Local/[email protected],300,tr,m(MusicClass))

Thank you for all the help. I hope this helps others as well…

/usr/sbin/sendmail $1 < $TMPFILE
gives me ==>
-bash: $TMPFILE: ambiguous redirect