Formatting and sendmail to use smtp_from fix (#2973)
* Fixed formatting. * Sendmail to use smtp_from variable Changed sendmail to use smtp_from as the from address to keep from being blocked by spf check during spam filtering on recieving end.
This commit is contained in:
committed by
FusionPBX
parent
b4f5ab888b
commit
3f9c9945a7
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
local send_mail
|
local send_mail
|
||||||
|
local Settings = require "resources.functions.lazy_settings"
|
||||||
|
local Database = require "resources.functions.database"
|
||||||
|
|
||||||
if not freeswitch then
|
if not freeswitch then
|
||||||
local Settings = require "resources.functions.lazy_settings"
|
|
||||||
local Database = require "resources.functions.database"
|
|
||||||
local log = require "resources.functions.log".sendmail
|
local log = require "resources.functions.log".sendmail
|
||||||
local sendmail = require "sendmail"
|
local sendmail = require "sendmail"
|
||||||
local uuid = require "uuid"
|
local uuid = require "uuid"
|
||||||
@@ -79,26 +79,33 @@ end
|
|||||||
|
|
||||||
if freeswitch then
|
if freeswitch then
|
||||||
function send_mail(headers, address, message, file)
|
function send_mail(headers, address, message, file)
|
||||||
local xheaders = "{"
|
local domain_uuid = headers["X-FusionPBX-Domain-UUID"]
|
||||||
for k,v in pairs(headers) do
|
local domain_name = headers["X-FusionPBX-Domain-Name"]
|
||||||
xheaders = xheaders .. ('"%s":"%s",'):format(k, v)
|
local email_type = headers["X-FusionPBX-Email-Type"] or 'info'
|
||||||
end
|
local call_uuid = headers["X-FusionPBX-Email-Type"]
|
||||||
xheaders = xheaders:sub(1,-2) .. '}'
|
local db = dbh or Database.new('system')
|
||||||
|
local settings = Settings.new(db, domain_name, domain_uuid)
|
||||||
|
local xheaders = "{"
|
||||||
|
for k,v in pairs(headers) do
|
||||||
|
xheaders = xheaders .. ('"%s":"%s",'):format(k, v)
|
||||||
|
end
|
||||||
|
xheaders = xheaders:sub(1,-2) .. '}'
|
||||||
|
|
||||||
local subject = message[1]
|
local from = settins:get('email', 'smtp_from', 'var')
|
||||||
local body = message[2] or ''
|
local subject = message[1]
|
||||||
|
local body = message[2] or ''
|
||||||
|
|
||||||
local mail_headers =
|
local mail_headers =
|
||||||
"To: ".. address .. "\n" ..
|
"To: ".. address .. "\n" ..
|
||||||
"From: " .. address .. "\n" ..
|
"From: " .. from .. "\n" ..
|
||||||
"Subject: " .. subject .. "\n" ..
|
"Subject: " .. subject .. "\n" ..
|
||||||
"X-Headers: " .. xheaders
|
"X-Headers: " .. xheaders
|
||||||
|
|
||||||
if file then
|
if file then
|
||||||
freeswitch.email(address, address, mail_headers, body, file)
|
freeswitch.email(address, from, mail_headers, body, file)
|
||||||
else
|
else
|
||||||
freeswitch.email(address, address, mail_headers, body)
|
freeswitch.email(address, from, mail_headers, body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user