27.11.2025, 11:25
Morning to everyone,
I tryed to do the same script, in my Comm Funct, I have:
And in my Event-Script I have:
The problem is that when I Run my Event script, I don't have any Log or Error, but I neither recive any e-mail in my account.
I will appreciate the help!
I tryed to do the same script, in my Comm Funct, I have:
Code:
function mail(to, subject, message)
-- make sure these settings are correct
local settings = {
-- "from" field, only e-mail must be specified here
from ='al*******@gmail.com',
-- smtp username
user = 'LM********',
-- smtp password
password = '********',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable ssl, required for gmail smtp
-- secure = 'tlsv1_2',
secure = 'sslv23'
}
local smtp = require('socket.smtp')
local escape = function(v)
return '<'..tostring..'>'
end
-- if type(to) ~= 'table' then
-- to = { to }
--end
-- for index, email in ipairs(to) do
-- to[ index ] = '<' .. tostring(email) .. '>'
--end
-- Fixup from field
-- local from = '<' ..tostring(settings.from)..'>'
-- message headers and body
settings.source = smtp.message({
headers = {
-- to = table.concat(to, ', '),
to = escape(to),
subject = subject,
--['From'] = settings.from,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
-- fixup from field
--settings.from = '<' .. tostring(settings.from) .. '>'
-- settings.from = from
settings.from = escape(settings.from)
--settings.rcpt = to
settings.rcpt = { escape(to)}
return smtp.send(settings)
endAnd in my Event-Script I have:
Code:
curr_value = event.getvalue()
prev_value = storage.get('prev_value')
if curr_value == prev_value then
return
end
storage.set('prev_value', curr_value)
os.sleep(10)
if curr_value then
subject = 'Main switch = PERMIT'
message = '\nState: Desbloqueado'
else
subject = 'Main switch = PROHIBIT'
message = '\nState: BLOQUEADO!!'
end
mail('ju*********@gmail.com', subject, message)The problem is that when I Run my Event script, I don't have any Log or Error, but I neither recive any e-mail in my account.
I will appreciate the help!