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:
parent
732f620eb2
commit
ff1ddaa1ae
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
local send_mail
|
||||
local Settings = require "resources.functions.lazy_settings"
|
||||
local Database = require "resources.functions.database"
|
||||
|
||||
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 sendmail = require "sendmail"
|
||||
local uuid = require "uuid"
|
||||
|
|
@ -79,26 +79,33 @@ end
|
|||
|
||||
if freeswitch then
|
||||
function send_mail(headers, address, message, file)
|
||||
local xheaders = "{"
|
||||
for k,v in pairs(headers) do
|
||||
xheaders = xheaders .. ('"%s":"%s",'):format(k, v)
|
||||
end
|
||||
xheaders = xheaders:sub(1,-2) .. '}'
|
||||
local domain_uuid = headers["X-FusionPBX-Domain-UUID"]
|
||||
local domain_name = headers["X-FusionPBX-Domain-Name"]
|
||||
local email_type = headers["X-FusionPBX-Email-Type"] or 'info'
|
||||
local call_uuid = headers["X-FusionPBX-Email-Type"]
|
||||
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 body = message[2] or ''
|
||||
local from = settins:get('email', 'smtp_from', 'var')
|
||||
local subject = message[1]
|
||||
local body = message[2] or ''
|
||||
|
||||
local mail_headers =
|
||||
"To: ".. address .. "\n" ..
|
||||
"From: " .. address .. "\n" ..
|
||||
"Subject: " .. subject .. "\n" ..
|
||||
"X-Headers: " .. xheaders
|
||||
local mail_headers =
|
||||
"To: ".. address .. "\n" ..
|
||||
"From: " .. from .. "\n" ..
|
||||
"Subject: " .. subject .. "\n" ..
|
||||
"X-Headers: " .. xheaders
|
||||
|
||||
if file then
|
||||
freeswitch.email(address, address, mail_headers, body, file)
|
||||
else
|
||||
freeswitch.email(address, address, mail_headers, body)
|
||||
end
|
||||
if file then
|
||||
freeswitch.email(address, from, mail_headers, body, file)
|
||||
else
|
||||
freeswitch.email(address, from, mail_headers, body)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue