Email send when extension or custom application dialed

is there a way to send an email when someone calls the extension or custom application ?

I tried to use this simple test but not sending emails, no errors

exten => s,1,TrySystem(mail -s " CALLER ${CALLERID(name)}# ${CALLERID(number)}"
exten => s,n,Return
exten => h,1,Macro(hangupcall,)

You’ll have to use a custom context prior to your queue it whatever.

Instead of using Return(), you’ll need to use Goto(${ARG1},${ARG2},${ARG3})

Try this:

same => n,System(echo -e 'Body Callback from:\\n ${CALLERID(num)} (${CALLERID(name)}) \\n on ${STRFTIME(${EPOCH},,%d.%m.%Y at %H:%M:%S)}' | mail -s "Subject Callback ${CALLERID(num)} - PBX" -r

Most of the time the is important so you e-mail-server will not reject that email on the way out.
Use as you did in the Vitalpbx email Settings.

And do what PitzKey said to keep on going with the destination you put in at the Custom Context module.

This might help you as well:
and this

Always try from small to big. Step by step to better find the problem.

1 Like


i see you create a lot of posts here in the forum.
Would you please mind reporting back when people try to help you?!

1 Like

my apolgies, here is my working context, when customer application invoked, this will send email with the callerID to zammad and also send a notification

you need to make few changes based on your zammad CTI URL and customer test you want to send

see attached file

custom context.txt (600 Bytes)

now, I am just trying to figure it how to use bash (awk) command in context

I want to add caller ID in the file /tmp/caller.txt file when context is invoked, here is my test, no errors, but doesn’t work, could some please guide me to the documentation to learn context scripting

exten => s,1, TrySystem(echo ${CALLERID(name)} > test.txt)

If this is working on cli/shell then this might be a permissions problem. There you mostly are “root” but in dialplans you are usually “asterisk”. You can check with “whoami” command.

Thanks , I will check

[root@phone vitalpbx]# whoami

I changed the permission on conf file
chmod 777 extensions__60001-custom.conf

exten => s,1, TrySystem(echo ${CALLERID(name)} > test.txt)

here is the output, but nothing in test.txt file

  • Executing [app-incoming@sub-set-call-vars:2] GotoIf(“PJSIP/1001_1-00000023”, “0?:return”) in new stack
    – Goto (sub-set-call-vars,app-incoming,6)
    – Executing [app-incoming@sub-set-call-vars:6] Return(“PJSIP/1001_1-00000023”, “”) in new stack
    – Executing [60010@cos-all-post:2] NoOp(“PJSIP/1001_1-00000023”, “Custom Application: service-noti-email-60010”) in new stack
    – Executing [60010@cos-all-post:3] Goto(“PJSIP/1001_1-00000023”, “custom-contexts,cc-19,1”) in new stack
    – Goto (custom-contexts,cc-19,1)
    – Executing [cc-19@custom-contexts:1] NoOp(“PJSIP/1001_1-00000023”, “service-noti-email-60010”) in new stack
    – Executing [cc-19@custom-contexts:2] Gosub(“PJSIP/1001_1-00000023”, “service-noti-email-60010,s,1(app-termination,hangup,1)”) in new stack

- Executing [s@service-noti-email-60010:1] TrySystem(“PJSIP/1001_1-00000023”, “echo Test1001 > test.txt”) in new stack

no, please check whoami in dialplan and get the output with NOOP for example.
Set the right permissions (chown and chmod) to your text.txt
Use Full path to test.txt in dialplan.

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