I'm new to this forum, and also a littel new to scripting in luna.
I have a Schneider HomeLynk with Wiser for KNX on. I'm trying some very simple thinks regarding sending Email. but I seams to have no luck getting ANY mail send what so ever.
I have now mad a new Gmail accound, and on that on enabled "allow acces for less secure apps" and changed nothing else than that on Gmail side
in script I have changed this to my new settings i common functions:
Code:
local settings = {
-- "from" field, only e-mail must be specified here
from = 'MYEMAIL@gmail.com',
-- smtp username
user = 'MYEMAIL@gmail.com',
-- smtp password
password = 'MYCODE',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable ssl, required for gmail smtp
secure = 'sslv23',
}
And in my triggered function i have this:
Code:
-- make sure mail settings are set in user function library before using this function
subject = 'There is new mail'
message = 'Med Venlig Hilsen Kastaniely'
mail('TEST@InoDes.dk', subject, message)
But nothing comes to my Emil, how do I debug that? and any good ideas what to do?
Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:
-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
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, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
20.08.2020, 10:19 (This post was last modified: 20.08.2020, 10:23 by Tue.)
(20.08.2020, 10:04)Daniel. Wrote: Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:
-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
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, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
settings.from = from
settings.rcpt = to
return smtp.send(settings)
end
Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:
Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
* nil
* arg: 2
* string: Try again
Using this code in triggered script
Code:
-- make sure mail settings are set in user function library before using this function
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)
(20.08.2020, 10:19)Tue Wrote:
(20.08.2020, 10:04)Daniel. Wrote: Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:
-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
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, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
settings.from = from
settings.rcpt = to
return smtp.send(settings)
end
Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:
Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
* nil
* arg: 2
* string: Try again
Using this code in triggered script
Code:
-- make sure mail settings are set in user function library before using this function
subject = 'Der er kommet post'
message = 'Med Venlig Hilsen Kastaniely'
res, err = mail('TSA@InoDes.dk', subject, message)
log(res, err)
--mail('TSA@InoDes.dk', subject, message)
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)
(20.08.2020, 10:19)Tue Wrote:
(20.08.2020, 10:04)Daniel. Wrote: Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:
-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
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, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
settings.from = from
settings.rcpt = to
return smtp.send(settings)
end
Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:
Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
* nil
* arg: 2
* string: Try again
Using this code in triggered script
Code:
-- make sure mail settings are set in user function library before using this function
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)
(20.08.2020, 10:19)Tue Wrote:
(20.08.2020, 10:04)Daniel. Wrote: Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:
-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
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, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
settings.from = from
settings.rcpt = to
return smtp.send(settings)
end
Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:
Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
* nil
* arg: 2
* string: Try again
Using this code in triggered script
Code:
-- make sure mail settings are set in user function library before using this function
subject = 'Der er kommet post'
message = 'Med Venlig Hilsen Kastaniely'
res, err = mail('TSA@InoDes.dk', subject, message)
log(res, err)
--mail('TSA@InoDes.dk', subject, message)
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)
Is there anything else in system, I can check (It has newer been able to send Email, have tryeid many times to get it to work). Any port in my Network (IP) that has to be speciel or anything else on server that can block it?
(20.08.2020, 10:29)admin Wrote: "Try again" error usually means that DNS resolve failed for some reason. Check that you have valid DNS set in Network > Interfaces > eth0.
I am trying to send email with above code but not successed. The ping is ok from LM to for example www.google.com. I have enabled less secure apps on the gmail account.
I have tried both of sslv23 and tlsv1_2 for secure. The log as below.