09.06.2022, 06:59
Hello
I have used the scripts below and I have also turned off the 2 step verification in google account
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 = 'XXXXXX@gmail.com',
-- smtp username
user = 'XXXXXX@gmail.com',
-- smtp password
password = 'XXXXXXX',
-- 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
require('user.Email')
Email("XXXXXX@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
Email("DDDDDD@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
log(mail("XXXXXX@gmail.com") )
it can't send an email and I have the error below
User script 5: attempt to call global 'mail' (a nil value)
stack traceback
er
I have used the scripts below and I have also turned off the 2 step verification in google account
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 = 'XXXXXX@gmail.com',
-- smtp username
user = 'XXXXXX@gmail.com',
-- smtp password
password = 'XXXXXXX',
-- 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
require('user.Email')
Email("XXXXXX@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
Email("DDDDDD@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
log(mail("XXXXXX@gmail.com") )
it can't send an email and I have the error below
User script 5: attempt to call global 'mail' (a nil value)
stack traceback
er