BugFix - make hangup and failure use send_mail() (#2974)

change the failure_handler and hangup apps use
resources.functions.send_mail so they can use the correct smtp_from*
settings
This commit is contained in:
Mafoo
2018-02-03 02:33:30 +00:00
committed by FusionPBX
parent 926995404f
commit 9724c1384e
2 changed files with 31 additions and 16 deletions

View File

@@ -34,6 +34,9 @@
require "resources.functions.trim";
require "resources.functions.base64";
--load libraries
require 'resources.functions.send_mail'
--check the missed calls
function missed()
if (missed_call_app ~= nil and missed_call_data ~= nil) then
@@ -55,10 +58,12 @@
end
--prepare the headers
headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",';
headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",';
headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",';
headers = headers..'"X-FusionPBX-Email-Type":"missed"}';
local headers = {
["X-FusionPBX-Domain-UUID"] = domain_uuid;
["X-FusionPBX-Domain-Name"] = domain_name;
["X-FusionPBX-Call-UUID"] = uuid;
["X-FusionPBX-Email-Type"] = 'missed';
}
--prepare the subject
local f = io.open(file_subject, "r");
@@ -88,13 +93,15 @@
body = body:gsub([["]], """);
body = trim(body);
--send the email
cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'";
--send the emails
send_mail(headers,
missed_call_data,
{subject, body}
);
if (debug["info"]) then
freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n");
freeswitch.consoleLog("notice", "[missed call] " .. caller_id_number .. "->" .. sip_to_user .. "emailed to " .. missed_call_data .. "\n");
end
api = freeswitch.API();
result = api:executeString(cmd);
end
end
end

View File

@@ -31,6 +31,9 @@
require "resources.functions.base64";
require "resources.functions.file_exists";
--load libraries
require 'resources.functions.send_mail'
--create the api object
api = freeswitch.API();
@@ -55,10 +58,12 @@
end
--prepare the headers
headers = '{"X-FusionPBX-Domain-UUID":"'..domain_uuid..'",';
headers = headers..'"X-FusionPBX-Domain-Name":"'..domain_name..'",';
headers = headers..'"X-FusionPBX-Call-UUID":"'..uuid..'",';
headers = headers..'"X-FusionPBX-Email-Type":"missed"}';
local headers = {
["X-FusionPBX-Domain-UUID"] = domain_uuid;
["X-FusionPBX-Domain-Name"] = domain_name;
["X-FusionPBX-Call-UUID"] = uuid;
["X-FusionPBX-Email-Type"] = 'missed';
}
--prepare the subject
local f = io.open(file_subject, "r");
@@ -89,11 +94,14 @@
body = trim(body);
--send the emails
cmd = "luarun email.lua "..missed_call_data.." "..missed_call_data.." "..headers.." '"..subject.."' '"..body.."'";
send_mail(headers,
missed_call_data,
{subject, body}
);
if (debug["info"]) then
freeswitch.consoleLog("notice", "[missed call] cmd: " .. cmd .. "\n");
freeswitch.consoleLog("notice", "[missed call] " .. caller_id_number .. "->" .. sip_to_user .. "emailed to " .. missed_call_data .. "\n");
end
result = api:executeString(cmd);
end
end
end