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 sending do not work
#1
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:
1234567891011121314
  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:
1234
-- 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?
Reply
#2
Log what the server reply is:
Code:
12
res, err = mail('TEST@InoDes.dk', subject, message) log(res, err)
Reply
#3
(20.08.2020, 09:35)admin Wrote: Log what the server reply is:
Code:
12
res, err = mail('TEST@InoDes.dk', subject, message) log(res, err)

This is the reply, what do that mean?


Code:
12345
Postkasse post ind 20.08.2020 11:21:26 * arg: 1   * nil * arg: 2   * string: Try again
Reply
#4
Which FW do you have? You need to change secure = 'sslv23', to secure = 'tlsv1_2',
Reply
#5
(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
Reply
#6
Left bottom corner of the main UI (Version: 20200720 or similar)
Reply
#7
(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 :-)

Attached Files Thumbnail(s)
   
Reply
#8
Change secure field in common functions and try again.
Reply
#9
(20.08.2020, 09:49)admin Wrote: Change secure field in common functions and try again.


Tried that, no luck


Code:
12345
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)
Reply
#10
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
Reply
#11
(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 Smile
Reply
#12
Check if you have DNS and gateway set correctly in Network interfaces, You can ping google.com form Network utilities in Status
------------------------------
Ctrl+F5
Reply
#13
I can from the system ping 8.8.8.8 (Google) and that works..
Reply
#14
Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
-- 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
------------------------------
Ctrl+F5
Reply
#15
(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:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
-- 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:
12345
Postkasse post ind 20.08.2020 12:01:21 * arg: 1   * nil * arg: 2   * string: Try again


Using this code in triggered script

Code:
1
-- make sure mail settings are set in user function library before using this function
Code:
1
subject = 'Der er kommet post'
Code:
1
message = 'Med Venlig Hilsen Kastaniely'
Code:
1
res, err = mail('TSA@InoDes.dk', subject, message)
Code:
1
log(res, err)
Code:
1
--mail('TSA@InoDes.dk', subject, message)
Code:
1
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:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
-- 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:
12345
Postkasse post ind 20.08.2020 12:01:21 * arg: 1   * nil * arg: 2   * string: Try again


Using this code in triggered script

Code:
123456789
-- 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:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
-- 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:
12345
Postkasse post ind 20.08.2020 12:01:21 * arg: 1   * nil * arg: 2   * string: Try again


Using this code in triggered script

Code:
1
-- make sure mail settings are set in user function library before using this function
Code:
1
subject = 'Der er kommet post'
Code:
1
message = 'Med Venlig Hilsen Kastaniely'
Code:
1
res, err = mail('TSA@InoDes.dk', subject, message)
Code:
1
log(res, err)
Code:
1
--mail('TSA@InoDes.dk', subject, message)
Code:
1
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:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
-- 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:
12345
Postkasse post ind 20.08.2020 12:01:21 * arg: 1   * nil * arg: 2   * string: Try again


Using this code in triggered script

Code:
123456789
-- 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?
Reply
#16
"Try again" error usually means that DNS resolve failed for some reason. Check that you have valid DNS set in Network > Interfaces > eth0.
Reply
#17
(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!!
Reply
#18
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
Reply
#19
Can you access our app store from this LM?
------------------------------
Ctrl+F5
Reply
#20
(23.11.2020, 09:55)Daniel. Wrote: Can you access our app store from this LM?

Yes, I can.
Reply


Forum Jump: