Multiple custom extensions for sending emails when called

Hey,
I’ve configured a custom extension that sends me an email if I’ve got a missed call. When the extension gets called, it sends an email to me and then hanging up using this script:

[send-email]
exten => s,1,NoOp(Entering user defined context  [send-email] in extensions_custom.conf)
exten => s,n,System(echo 'Call from ${CALLERID(name)} at  ${CALLERID(number)}' | mail -s 'SUBJECT' '[email protected]')
exten => s,n,hangup()

The dial field of the custom extension is set to
local/s@send-email

I’ve got this from lgaetz.
I’d like to know how I can accomplish this for a second extension, I don’t really know how this stuff works, but I’m willing to learn.
If configuring the same thing and changing the “s” to “t” so the two codes can be differentiated, but then it doesn’t send anything at all.
Help?

Change the dialplan to:

[send-email]
exten => _.,1,NoOp(Entering user defined context  [send-email] in extensions_custom.conf)
exten => _.,n,set(emailaddresss=${STRREPLACE(EXTEN,:,@)})
exten => _.,n,System(echo 'Call from ${CALLERID(name)} at  ${CALLERID(number)}' | mail -s 'SUBJECT' '${emailaddresss}')
exten => _.,n,hangup()

Then the custom dial string becomes:

local/email:domain.com@send-email

you replace the @ symbol in the email address with a :

1 Like

Curious. How does this get called?

You can’t remember posts from 4 years ago?

2 Likes

Lol, you rock man.

I was actually working recently on a similar project. Is there a possibility to pull the email address set in the Voicemail tab or in user management and set as a variable?

You could certainly do it with a custom bit of SQL. I have no idea if those values are exposed any other way, but I doubt it.

I have a custom MySQL database at one site with a lot of data in it that is pulled in for outbound call checks. So for something like this, you should just need to add a call to the asterisk database to pull the info.

You can grep it out of the conf file

 grep ^${EXTEN}/etc/asterisk/voicemail.conf|cut -d ',' -f 3
1 Like

I’ve modified the code slightly

[send-email-privat]
exten => _.,1,NoOp(Entering user defined context [send-email-privat] in extensions_custom.conf)
exten => _.,n,System(echo ‘Anrufer “${CALLERID(name)}” mit der Telefonnummer “${CALLERID(number)}” bittet um Rückruf. (Anschluss 12345)’ | mail -s ‘Ein Rückruf wurde angefordert’ ‘[email protected]’)
exten => _.,n,hangup()

Dialpattern is

local/xy@send-email-privat

But now it always send the same email twice. Any idea why?

That will only work if the extension has voicemail enabled on it.

Damn, your right!! Never thought about that (looking for the correct emoticon here . . .)

Here are some recommendations: :sweat_smile::thinking::open_mouth:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.