Send a email when a DID is called?

I was wondering if there was a way to setup a email to be sent with the number calling CNAM info each time a DID is called. We use it for call tracking in our helpdesk software

So lets say “John Smith CNAM” calls 777-777-7777 when that DID is called it would send of an email to [email protected]

Subject: CNAM 777-777-777 Has Called
Body: You have just received a call from CNAM 777-777-777 If you have not already please speak with them as soon as possible.

Something like this, then we can send that into our helpdesk and it will create a ticket so was can track calls.

All and any help with would be greatly appricated.

Hi!

CID Superfecta can do this if you configure its “send to email” entry (“This module will send a notification email for all inbound calls to the user supplied email addresses.”).

Have a nice day!

Nick

Is is possible to program this for a specific DID? Do you have any pointers on setting this up?

Your example is a bit unclear because you use 777-777-7777 as both the DID and the caller’s Caller ID number, which would not be a typical call. But nevertheless I think this would work:

Create a custom destination:

In the Custom Destination field, put something like
custom-send-email,s,1
Check the “Return” box
Make the destination the same as the current destination of your DID.

In /etc/asterisk/extensions_custom.conf add the context you used above (custom-send-email in this example) and use something like this:

[custom-send-email]
exten => s,1,TrySystem(echo “Call from ${CALLERID(name)} at ${CALLERID(number)} received ${STRFTIME(${EPOCH},%l:%M:%S %p %Z on %A %B %e)}” | mail [email protected])
exten => s,n,Return
exten => h,1,Macro(hangupcall,)

Finally go to your DID and set the destination to be the new custom destination. So the call will come in on the DID, go to your bit of custom dialplan in extensions_custom.conf, and then continue on the the original destination. I’m not that familiar with the syntax of the mail command in Linux, but if you look at the man page or Google some examples you’ll likely find how to add a subject line, and obviously you can change the content to whatever you want it to say.

Before doing this you may want to try manually sending a short email from the command line using the mail command, just to make sure that works. It should if you are receiving other mails from the system, but I would not assume anything.

With CID Superfecta I think you would have to do another CID Superfecta scheme and assign it to that specific DID…

Good luck and have a nice day!

Nick

you are the best ok here is what i got, i’ve changed the last 4 digits of my number to protect it

Subject:
None “its there any way to add that?”

Body:
Call from 15615041200 at 15615041200 received 7:43:03 PM EDT on Thursday September 3

Couple Of Questions:
Can I define the sender email address? now it looks like it’s coming from asterisk
Is there any way to add the Caller ID Name “So it would include the actual CNAME name and the phone number”

Hi!

:blush:

What version of CID Superfecta do you have?

Mine (but I am running the FreePBX 13 beta) permits setting a subject and (but I can’t test it right now, I am rebuilding my server) apparently shows the name as well…

The subject line is supposed to be something like this:

“Incoming call from [NAME] at [NUMBER]”

with the version I have

As for the email if you can give a little more info as to what you are running I am sure I can probably find where it takes it (or with a little luck one of its dev will pop up in this thread…).

I have one question though, where did you put the call to “send to email” in the CID Superfecta scheme, after obtaining looking up the CNAME from one of the databases, right?

(It’s most likely important…)

Have a nice day!

Nick

Ok Editor, Thank you this worked perfect. My only question is can i specify the from email address?

I think you can.
Can you give an example what do you want to do exactly?

Ok Currently my custom script looks like this

[custom-send-email]
exten => s,1,TrySystem(echo “Call from ${CALLERID(name)} at ${CALLERID(number)} received ${STRFTIME(${EPOCH},%l:%M:%S %p %Z on %A %B %e)}” | mail -s " CALLER ${CALLERID(name)}# ${CALLERID(number)}" [email protected] -aFrom:[email protected])
exten => s,n,Return
exten => h,1,Macro(hangupcall,)

now when i get the email everything is perfect except the from address is [email protected]

is there any way i can have the from address be "[email protected]"

in advanced settings,
search (Email “From:” Address)
write your email and then please try again.

yes but i would like to use the actual phone number
so lets say call comes in from 1111111111
the email will be [email protected] from

I really don’t think that using fake email addresses would be very good, you would not be a very good Netizen…

That said, you could put the phone number in a friendly name…

ie something like this:

From: 1111111111 <[email protected]> 

and/or use the fact that the envelope sender and the “From:” header don’t actually have to match (the From: header is actually only there for our benefit, not for email routing…

Unfortunately I don’t believe “mail” let’s you access any of this…

You would have to use a more complex script and something like sendmail directly…

Good luck and have a nice day!

Nick