25.01.2020, 17:17
I have the scripts below. Please tell me what to do.
Email function in user libraries
function Email(to, subject, message)
-- make sure these settings are correct
---------------BEGINNING OF USER EDITABLE AREA-------------------
local settings = {
-- "from" field, only e-mail must be specified here
from = 'christ.spagakas@gmail.com',
-- smtp username
user = 'christ.spagakas@gmail.com',
-- smtp password
password = '..............',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable ssl, required for gmail smtp
secure = 'tlsv1_2',
}
-------------------END OF USER EDITABLE AREA---------------------
local smtp = require('socket.smtp')
local escape = function(v)
return '<' .. tostring(v) .. '>'
end
-- message headers and body
settings.source = smtp.message({
headers = {
to = escape(to),
subject = subject,
},
body = message
})
-- fixup from field
settings.from = escape(settings.from)
settings.rcpt = { escape(to) }
return smtp.send(settings)
end
This in common functions
-- user function library
-- send an e-mail,
--function mail(to, subject, message)
-- make sure these settings are correct
--local settings = {
-- "from" field, only e-mail must be specified here
-- from = 'christ.spagakas@gmail.com',
-- smtp username
-- user = 'christ.spagakas@gmail.com',
-- smtp password
-- password = '.....................',
-- smtp server
-- server = 'smtp.gmail.com',
-- smtp server port
-- port = 465,
-- enable ssl, required for gmail smtp
-- secure = 'sslv23',
--}
--local smtp = require('socket.smtp')
--local escape = function(v)
-- return '<' .. tostring(v) .. '>'
--end
-- message headers and body
--settings.source = smtp.message({
--headers = {
--to = escape(to),
--subject = subject,
--},
--body = message
--})
-- fixup from field
--settings.from = escape(settings.from)
--settings.rcpt = { escape(to) }
--return smtp.send(settings)
--end
and the script below for event
mail("christ.spagakas@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
mail("v.matziri@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
or
email("christ.spagakas@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
email("v.matziri@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
Email function in user libraries
function Email(to, subject, message)
-- make sure these settings are correct
---------------BEGINNING OF USER EDITABLE AREA-------------------
local settings = {
-- "from" field, only e-mail must be specified here
from = 'christ.spagakas@gmail.com',
-- smtp username
user = 'christ.spagakas@gmail.com',
-- smtp password
password = '..............',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable ssl, required for gmail smtp
secure = 'tlsv1_2',
}
-------------------END OF USER EDITABLE AREA---------------------
local smtp = require('socket.smtp')
local escape = function(v)
return '<' .. tostring(v) .. '>'
end
-- message headers and body
settings.source = smtp.message({
headers = {
to = escape(to),
subject = subject,
},
body = message
})
-- fixup from field
settings.from = escape(settings.from)
settings.rcpt = { escape(to) }
return smtp.send(settings)
end
This in common functions
-- user function library
-- send an e-mail,
--function mail(to, subject, message)
-- make sure these settings are correct
--local settings = {
-- "from" field, only e-mail must be specified here
-- from = 'christ.spagakas@gmail.com',
-- smtp username
-- user = 'christ.spagakas@gmail.com',
-- smtp password
-- password = '.....................',
-- smtp server
-- server = 'smtp.gmail.com',
-- smtp server port
-- port = 465,
-- enable ssl, required for gmail smtp
-- secure = 'sslv23',
--}
--local smtp = require('socket.smtp')
--local escape = function(v)
-- return '<' .. tostring(v) .. '>'
--end
-- message headers and body
--settings.source = smtp.message({
--headers = {
--to = escape(to),
--subject = subject,
--},
--body = message
--})
-- fixup from field
--settings.from = escape(settings.from)
--settings.rcpt = { escape(to) }
--return smtp.send(settings)
--end
and the script below for event
mail("christ.spagakas@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
mail("v.matziri@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
or
email("christ.spagakas@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
email("v.matziri@gmail.com", "Alarm", "Παραβίαση Σπιτιού")