Voicemail-to-Email: Add custom headers containing domain_uuid, domain_name, call_uuid and email_type. Send email using Domain smtp settings, if defined under Default Settings.

This commit is contained in:
Nate Jones
2014-07-08 02:30:57 +00:00
parent dba82d6d5a
commit 7713c9a6e9
4 changed files with 98 additions and 43 deletions
@@ -87,6 +87,12 @@
moderator_pin = string.lower(row["moderator_pin"]);
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":"na",';
headers = headers..'"X-FusionPBX-Email-Type":"conference"}';
--prepare the subject
local f = io.open(file_subject, "r");
local subject = f:read("*all");
@@ -118,9 +124,9 @@
--send the email
if (string.len(attachment) > 4) then
cmd = "luarun email.lua "..email.." "..email.." '"..subject.."' '"..body.."' '"..attachment.."'";
cmd = "luarun email.lua "..email.." "..email.." '"..headers.."' '"..subject.."' '"..body.."' '"..attachment.."'";
else
cmd = "luarun email.lua "..email.." "..email.." '"..subject.."' '"..body.."'";
cmd = "luarun email.lua "..email.." "..email.." '"..headers.."' '"..subject.."' '"..body.."'";
end
if (debug["info"]) then
freeswitch.consoleLog("notice", "[voicemail] cmd: " .. cmd .. "\n");
@@ -84,6 +84,12 @@
file_body = scripts_dir.."/app/voicemail/resources/templates/en/us/email_body.tpl";
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":"voicemail"}';
--prepare the subject
local f = io.open(file_subject, "r");
local subject = f:read("*all");
@@ -124,9 +130,9 @@
delete = "false";
end
file = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
cmd = "luarun email.lua "..voicemail_mail_to.." "..voicemail_mail_to.." '"..subject.."' '"..body.."' '"..file.."' "..delete;
cmd = "luarun email.lua "..voicemail_mail_to.." "..voicemail_mail_to.." "..headers.." '"..subject.."' '"..body.."' '"..file.."' "..delete;
else
cmd = "luarun email.lua "..voicemail_mail_to.." "..voicemail_mail_to.." '"..subject.."' '"..body.."'";
cmd = "luarun email.lua "..voicemail_mail_to.." "..voicemail_mail_to.." "..headers.." '"..subject.."' '"..body.."'";
end
if (debug["info"]) then
freeswitch.consoleLog("notice", "[voicemail] cmd: " .. cmd .. "\n");
+10 -9
View File
@@ -42,12 +42,13 @@
script_name = argv[0];
to = argv[1];
from = argv[2];
subject = argv[3];
body = argv[4];
file = argv[5];
delete = argv[6];
--convert_cmd = argv[7];
--convert_ext = argv[8];
headers = argv[3];
subject = argv[4];
body = argv[5];
file = argv[6];
delete = argv[7];
--convert_cmd = argv[8];
--convert_ext = argv[9];
--replace the &#39 with a single quote
body = body:gsub("'", "'");
@@ -59,21 +60,21 @@
if (file == nil) then
freeswitch.email("",
"",
"To: "..to.."\nFrom: "..from.."\nSubject: "..subject,
"To: "..to.."\nFrom: "..from.."\nX-Headers: "..headers.."\nSubject: "..subject,
body
);
else
if (convert_cmd == nil) then
freeswitch.email("",
"",
"To: "..to.."\nFrom: "..from.."\nSubject: "..subject,
"To: "..to.."\nFrom: "..from.."\nX-Headers: "..headers.."\nSubject: "..subject,
body,
file
);
else
freeswitch.email("",
"",
"To: "..to.."\nFrom: "..from.."\nSubject: "..subject,
"To: "..to.."\nFrom: "..from.."\nX-Headers: "..headers.."\nSubject: "..subject,
body,
file,
convert_cmd,