Send notification email for each outgoing call, how?

First of all… Yes, this is mainly a FreePBX question (but is applicable to no-GUI Asterisk). I did ask the question on the FreePBX forum and was not able to get an answer. I have also Googled everything I can think of, over the last three days, trying to find the answer with no success. So I’m asking you experts here to please bear with me and give me a hand with this problem.

I maintain a PBX for a statewide non-profit public-service volunteer organization, using FreePBX, Asterisk 1.8.15. They don’t do many outbound calls there at the non-profit; most calls are inbound, or intra-network (i.e. from one PBX extension to another). Because of the hacking episode I recently (last few days) suffered and described in another post on this forum, I would like to arrange to receive an email on my cell phone whenever anyone makes an outbound call, including the outbound route used, and the number called.

Here’s what I’ve done so far, just to get the basics of this working, and so far no joy.

My out-of-the-box extensions_additional.conf, which FreePBX auto-generates and which is #include’d in extensions.conf which also #include’s extensions_custom.conf (so, all three of these should be visible), contains this:

[outrt-1] ; RouteName1
include => outrt-1-custom
exten => _9NXXXXXX,1,(rule)…
…then a bunch of dial plan rules, all of which work. This rule requires dialing 9 to get an outside line (which also works).

My extensions_custom.conf file, that I hand-edit, contains this to (a) send an empty email to my cell phone, just alerting me (by the subject of the email) that an outgoing call is happening; and (b) put an empty file in /etc/asterisk with the filename “junk.outrt” so I’ll know the sequence was executed:

exten => _9NXXXXXX,1,System(mail -s “Call out” < /dev/null)
exten => _9NXXXXXX,n,System(touch junk.outrt)

No joy… no email received on my cell, and no junk.outrt file in /etc/asterisk.

I did try hand-executing mail -s “Call out” < /dev/null just to verify that I have the mail calling syntax correct, and it works.

As I said this is just to get the basics running… then I’ll deal with how to put useful information in the mail subject line, like number called, date/time, etc. (I have found a website that discusses various Asterisk variables).

Since I’m not making a dime off of this thing and in fact am paying some of the phone expenses out of my pocket on behalf of the non-profit, including the estimated US$130+ that last weekend’s hacking episode cost me, and since I feel like I’ve done my homework as best I can, I’m really hoping someone here can overlook that this is basically a FreePBX question, and give me a hand getting this working.

I’m sure it’s some basic noob thing… thanks…

Eric in NH

I guess you ran the commands as root, since Freepbx run as asterisk check the permissions, also try using a bash script or set the full path of the applications in the system command.

You can use the extensions_override file to only have 1 junk of code. You copy the complete context outrt-1 and then you add your lines there.