2020-05-20 23:13:28 +02:00
|
|
|
|
|
|
|
local data = ...
|
2020-05-23 20:09:01 +02:00
|
|
|
-- print(data.content)
|
|
|
|
local error_msg = {}
|
|
|
|
local iserror = false
|
2020-05-20 23:13:28 +02:00
|
|
|
for k,v in pairs(data.to) do
|
|
|
|
print("sent to:"..v)
|
|
|
|
local to = v
|
2020-06-05 20:06:10 +02:00
|
|
|
local from = "From: mrsang@lxsang.me\n"
|
2020-05-20 23:13:28 +02:00
|
|
|
local suject = "Subject: " .. data.title .. "\n"
|
|
|
|
local content = data.content.."\n"
|
|
|
|
local cmd = 'echo "' .. utils.escape(from .. suject .. content) .. '"| sendmail ' .. to
|
|
|
|
--print(cmd)
|
|
|
|
local r = os.execute(cmd)
|
|
|
|
if not r then
|
2020-05-23 20:09:01 +02:00
|
|
|
iserror = true
|
|
|
|
table.insert(error_msg, v)
|
|
|
|
print("Unable to send mail to: "..v)
|
2020-05-20 23:13:28 +02:00
|
|
|
end
|
|
|
|
end
|
2020-05-23 20:09:01 +02:00
|
|
|
local result = {}
|
|
|
|
result.error = iserror
|
|
|
|
result.result = error_msg
|
|
|
|
return result
|