Email sending do not work - Tue - 20.08.2020
Hello There
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?
RE: Email sending do not work - admin - 20.08.2020
Log what the server reply is:
Code: res, err = mail('TEST@InoDes.dk', subject, message)
log(res, err)
RE: Email sending do not work - Tue - 20.08.2020
(20.08.2020, 09:35)admin Wrote: Log what the server reply is:
Code: res, err = mail('TEST@InoDes.dk', subject, message)
log(res, err)
This is the reply, what do that mean?
Code: Postkasse post ind 20.08.2020 11:21:26
* arg: 1
* nil
* arg: 2
* string: Try again
RE: Email sending do not work - admin - 20.08.2020
Which FW do you have? You need to change secure = 'sslv23', to secure = 'tlsv1_2',
RE: Email sending do not work - Tue - 20.08.2020
(20.08.2020, 09:38)admin Wrote: Which FW do you have? You need to change secure = 'sslv23', to secure = 'tlsv1_2',
Where do I see FW version?
(20.08.2020, 09:38)admin Wrote: Which FW do you have? You need to change secure = 'sslv23', to secure = 'tlsv1_2', Lower left corner says Version 2.4.0 in my browser
RE: Email sending do not work - admin - 20.08.2020
Left bottom corner of the main UI (Version: 20200720 or similar)
RE: Email sending do not work - Tue - 20.08.2020
(20.08.2020, 09:42)admin Wrote: Left bottom corner of the main UI (Version: 20200720 or similar) Look at attached
(20.08.2020, 09:42)admin Wrote: Left bottom corner of the main UI (Version: 20200720 or similar) Now attached :-)
RE: Email sending do not work - admin - 20.08.2020
Change secure field in common functions and try again.
RE: Email sending do not work - Tue - 20.08.2020
(20.08.2020, 09:49)admin Wrote: Change secure field in common functions and try again.
Tried that, no luck
Code: Postkasse post ind 20.08.2020 11:35:13
* arg: 1
* nil
* arg: 2
* string: Try again
How do I check if it can se the internet? It sams like 0.dk.pool.ntp.org do not work either (Just seen that the system clock has driftet)
RE: Email sending do not work - Erwin van der Zwart - 20.08.2020
Hi,
Did you enabled "less secure apps" in your gmail account? If not you will not be able to send mail..
To check your internet you can open the appstore or do a ping from the network tools..
BR,
Erwin
RE: Email sending do not work - Tue - 20.08.2020
(20.08.2020, 09:54)Erwin van der Zwart Wrote: Hi,
Did you enabled "less secure apps" in your gmail account? If not you will not be able to send mail..
BR,
Erwin Yes I did
RE: Email sending do not work - Daniel - 20.08.2020
Check if you have DNS and gateway set correctly in Network interfaces, You can ping google.com form Network utilities in Status
RE: Email sending do not work - Tue - 20.08.2020
I can from the system ping 8.8.8.8 (Google) and that works..
RE: Email sending do not work - Daniel - 20.08.2020
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
RE: Email sending do not work - Tue - 20.08.2020
(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
Code: subject = 'Der er kommet post'
Code: message = 'Med Venlig Hilsen Kastaniely'
Code: res, err = mail('TSA@InoDes.dk', subject, message)
Code: --mail('TSA@InoDes.dk', subject, message)
Code: 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
Code: subject = 'Der er kommet post'
Code: message = 'Med Venlig Hilsen Kastaniely'
Code: res, err = mail('TSA@InoDes.dk', subject, message)
Code: --mail('TSA@InoDes.dk', subject, message)
Code: 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?
RE: Email sending do not work - admin - 20.08.2020
"Try again" error usually means that DNS resolve failed for some reason. Check that you have valid DNS set in Network > Interfaces > eth0.
RE: Email sending do not work - Tue - 20.08.2020
(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. The DNS was wrong! :-)!!!!!!!
Now it is working!!
RE: Email sending do not work - Ibrahim - 20.11.2020
Hello,
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.
* arg: 1
* nil
* arg: 2
* string: timeout
RE: Email sending do not work - Daniel - 23.11.2020
Can you access our app store from this LM?
RE: Email sending do not work - Ibrahim - 23.11.2020
(23.11.2020, 09:55)Daniel. Wrote: Can you access our app store from this LM?
Yes, I can.
|