mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2025-07-13 14:14:27 +02:00
fix: relese regen
All checks were successful
gitea-sync/antosdk-apps/pipeline/head This commit looks good
All checks were successful
gitea-sync/antosdk-apps/pipeline/head This commit looks good
This commit is contained in:
@ -1,37 +1,65 @@
|
||||
|
||||
local data = ...
|
||||
-- load the smtp support
|
||||
local smtp = require("socket.smtp")
|
||||
|
||||
local from = string.format("<%s@iohub.dev>", data.user);
|
||||
|
||||
local mesgt = {
|
||||
headers = {
|
||||
from = string.format("Dany <%s@iohub.dev>", data.user),
|
||||
to = "",
|
||||
subject = data.title
|
||||
},
|
||||
body = data.content
|
||||
}
|
||||
-- Michal Kottman, 2011, public domain
|
||||
local socket = require 'socket'
|
||||
local smtp = require 'socket.smtp'
|
||||
local ssl = require 'ssl'
|
||||
local https = require 'ssl.https'
|
||||
local ltn12 = require 'ltn12'
|
||||
|
||||
function sslCreate()
|
||||
local sock = socket.tcp()
|
||||
return setmetatable({
|
||||
connect = function(_, host, port)
|
||||
local r, e = sock:connect(host, port)
|
||||
if not r then return r, e end
|
||||
sock = ssl.wrap(sock, {mode='client', protocol='tlsv1_2'})
|
||||
return sock:dohandshake()
|
||||
end
|
||||
}, {
|
||||
__index = function(t,n)
|
||||
return function(_, ...)
|
||||
return sock[n](sock, ...)
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
function sendMail(user, password, to,subject, body)
|
||||
local msg = {
|
||||
headers = {
|
||||
from = string.format("%s <%s@iohub.dev>", user, user),
|
||||
to = string.format("%s <%s>",to.text, to.email),
|
||||
subject = subject
|
||||
},
|
||||
body = body
|
||||
}
|
||||
|
||||
local ok, err = smtp.send {
|
||||
from = string.format('<%s@iohub.dev>', user),
|
||||
rcpt = string.format('<%s>', to.email),
|
||||
source = smtp.message(msg),
|
||||
user = string.format('%s@iohub.dev', user),
|
||||
password = password,
|
||||
server = 'iohub.dev',
|
||||
port = 465,
|
||||
create = sslCreate
|
||||
}
|
||||
if not ok then
|
||||
return false, error
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local error_msg = {}
|
||||
local iserror = false
|
||||
|
||||
for k,v in pairs(data.to) do
|
||||
LOG_DEBUG("Send email to:"..v.email)
|
||||
local rcpt = string.format("<%s>",v.email)
|
||||
mesgt.headers.to = string.format("%s <%s>",v.text, v.email)
|
||||
local r, e = smtp.send{
|
||||
from = from,
|
||||
rcpt = rcpt,
|
||||
server = "iohub.dev",
|
||||
domain = "iohub.dev",
|
||||
user = data.user,
|
||||
password = data.password,
|
||||
source = smtp.message(mesgt)
|
||||
}
|
||||
|
||||
local r = os.execute(cmd)
|
||||
local r,e = sendMail(data.user, data.password, v, data.title, data.content)
|
||||
if not r then
|
||||
iserror = true
|
||||
table.insert(error_msg, v.email)
|
||||
|
Reference in New Issue
Block a user