This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Email function
#9
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", "Παραβίαση Σπιτιού")
Reply


Messages In This Thread
Email function - by XSPA2474KW - 25.01.2020, 07:40
RE: Email function - by Erwin van der Zwart - 25.01.2020, 08:47
RE: Email function - by XSPA2474KW - 25.01.2020, 13:54
RE: Email function - by admin - 25.01.2020, 13:56
RE: Email function - by XSPA2474KW - 25.01.2020, 14:55
RE: Email function - by admin - 25.01.2020, 15:28
RE: Email function - by XSPA2474KW - 25.01.2020, 16:14
RE: Email function - by Erwin van der Zwart - 25.01.2020, 16:57
RE: Email function - by XSPA2474KW - 25.01.2020, 17:17
RE: Email function - by Erwin van der Zwart - 25.01.2020, 17:43
RE: Email function - by XSPA2474KW - 25.01.2020, 18:07
RE: Email function - by Domoticatorino - 06.06.2020, 23:55
RE: Email function - by admin - 07.06.2020, 07:26
RE: Email function - by Domoticatorino - 07.06.2020, 09:12
RE: Email function - by Domoticatorino - 08.06.2020, 08:02
RE: Email function - by admin - 08.06.2020, 08:11
RE: Email function - by Domoticatorino - 08.06.2020, 08:33
RE: Email function - by admin - 08.06.2020, 08:36
RE: Email function - by toujour - 13.06.2020, 09:54
RE: Email function - by Domoticatorino - 13.06.2020, 14:42
RE: Email function - by admin - 13.06.2020, 16:06
RE: Email function - by Domoticatorino - 15.06.2020, 14:48

Forum Jump: