Logic Machine Forum
Email sending do not work - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Email sending do not work (/showthread.php?tid=2800)

Pages: 1 2


RE: Email sending do not work - Ibrahim - 26.11.2020

Hello,

I have changed to mail server from gmail to the customer account and I get below error.


* arg: 1
* nil
* arg: 2
* string: wantread

What does it mean?

Thanks.


RE: Email sending do not work - admin - 27.11.2020

wantread is an SSL-related message. What firmware version and which email provider are you using?


RE: Email sending do not work - Ibrahim - 27.11.2020

Hi admin,
exc
firmware version is SW: 20191015. They are using microsoft exchange server for mail accounts and created an account for logic machine.

Also I have tried with gmail smtp and I get below error;

* arg: 1
* nil
* arg: 2
* string: timeout


RE: Email sending do not work - admin - 27.11.2020

This can possibly be some firewall/router issue. Try this script and post what you get in Logs tab:
Code:
require('socket')
ssl = require('ssl')

s = socket.tcp()
s:settimeout(5)

res, err = s:connect('smtp.gmail.com', 465)
log('connect', res, err)
if res then
  res, err = ssl.wrap(s, { mode = 'client', protocol = 'tlsv12' })
  log('wrap', res, err)

  if res then
    s = res
    s:settimeout(5)
    res, err = s:dohandshake()
    log('handshake', res, err)

    if res then
      res, err = s:receive('*l')
      log('receive', res, err)
    end
  end
end
s:close()
You can also replace 'smtp.gmail.com', 465 with another host/port with SSL support to test the connection.


RE: Email sending do not work - Ibrahim - 27.11.2020

Hi admin,

The log for gmail is:
"Event for Mail (32/1/39) 27.11.2020 22:54:47
* arg: 1
* string: connect
* arg: 2
* nil
* arg: 3
* string: timeout"

The log for local account;

"Event for Mail (32/1/39) 27.11.2020 23:01:10
* arg: 1
* string: connect
* arg: 2
* number: 1
* arg: 3
* nil
Event for Mail (32/1/39) 27.11.2020 23:01:10
* arg: 1
* string: wrap
* arg: 2
* SSL connection: 0xb6f0eda8
* arg: 3
* nil
Event for Mail (32/1/39) 27.11.2020 23:01:10
* arg: 1
* string: handshake
* arg: 2
* bool: true
* arg: 3
* nil
Event for Mail (32/1/39) 27.11.2020 23:01:15
* arg: 1
* string: receive
* arg: 2
* nil
* arg: 3
* string: wantread


RE: Email sending do not work - admin - 30.11.2020

The first error means that LM cannot connect to gmail at all. It might be caused by router/firewall or simply incorrect/missing gateway and DNS settings in LM.
The second error means that the mail server is not sending enough data for the encryption layer to decrypt. Have you tried your local server without encryption? Set port to 25 and comment or remove "secure" line from the mail settings.


RE: Email sending do not work - BrentW - 24.03.2021

(30.11.2020, 07:35)admin Wrote: The first error means that LM cannot connect to gmail at all. It might be caused by router/firewall or simply incorrect/missing gateway and DNS settings in LM.
The second error means that the mail server is not sending enough data for the encryption layer to decrypt. Have you tried your local server without encryption? Set port to 25 and comment or remove "secure" line from the mail settings.
Hi Admin,

I'm battling away with a similar problem.
I'm confident I have the correct DNS settings and Gateway settings. 
I am continually seeing wantread errors.
The IT department have naturally assured me its something in my LM(Clipsal Nac) but I am certainly confident it isn't. Usual battles with buck passing.
Is it possible for you to suggest a list of items on their end to check to ensure it is possible to connect.
Version is 1.6 but i think thats a clipsal version number?
what SSL would be best? I've tried sslv23 and tlsv1_2.

Brent


RE: Email sending do not work - admin - 24.03.2021

Are you using my test script? Does it get to the dohandshake or receive part?


RE: Email sending do not work - BrentW - 25.03.2021

(24.03.2021, 09:22)admin Wrote: Are you using my test script? Does it get to the dohandshake or receive part?

Yeah, using your test script.
See photo for results. Handshake and receive are both present.


RE: Email sending do not work - admin - 25.03.2021

Have you checked if there's a newer firmware available? This issue might also be caused by an old SSL library.


RE: Email sending do not work - BrentW - 06.04.2021

(25.03.2021, 07:14)admin Wrote: Have you checked if there's a newer firmware available? This issue might also be caused by an old SSL library.

Unfortunately I'm bound by the rather slow release of firmware for the clipsal/schneider Shac/Nac product line.
Their firmware number is 1.6.0 but I don't know how that relates to the LM firmware number.
The last update was issued in August 2018!!!!! I'm made a few enquiries to them on this issue don't worry.

Can you explain the wantread result? 
If I was to get the facility to create a certificate for the NAC under their domain would that improve the SSL issue if it exists?
Seeing as the Gmail work around is to enable less trustworthy devices this might be where the conflict lies in the process?

Brent


RE: Email sending do not work - admin - 06.04.2021

SSL certificate is for the server mode whereas sending email is done in client mode. Enabling less secure apps won't do anything because the script fails before the login happens. Wantread means that there's not enough data (or no data at all) to be read from the server. During normal operation at this point the SMTP server sends a greeting line to the client.
Alternative solution is to use a mail sending service that has API so you can send via HTTPS requests instead of SMTP. Try https://sendgrid.com/ or https://www.mailjet.com/