Logic Machine Forum
mail function does not work for me - 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: mail function does not work for me (/showthread.php?tid=2514)



mail function does not work for me - Hyxion14 - 15.03.2020

Hello, I am trying to use the mail function, but it doesn't work for me.

This is the function setting:


function mail(to, subject, message)
  -- make sure these settings are correct
  local settings = {
    -- "from" field, only e-mail must be specified here
    from = 'LM-ANA@x-domotica.com',
    -- smtp username
    user = 'LM-ANA@x-domotica.com',
    -- smtp password
    password = '................',
    -- smtp server
    server = 'mail.x-domotica.com',
    -- smtp server port
    port = 587,
    -- enable tls, required for gmail smtp
    secure = 'none',
    starttls = false,
  }


Nor does it record anything in Log.

The only message I have is in the error log and it says:

Library socket / tp: 0: attempt to index a nil value
stack traceback:
  [C]: in function 'mail'
  User script: 8: in main chunk


Why dont work?

Thanks very much for your help.


RE: mail function does not work for me - admin - 15.03.2020

Port 587 usually requires starttls mode. Have you tried enabling it? Keep in mind that starttls might not work on older firmware versions.


RE: mail function does not work for me - Hyxion14 - 15.03.2020

I have tested this Mozilla Thunderbird account setup and it works without STARTTLS on port 587, so I have added STARTTLS = "false" to it.

I have tried putting STARTTLS = "true" and it doesn't work for me either.

If I put STARTTLS = true

In the LOG the message appears:

* arg: 1
  * nil
* arg: 2
  * string: invalid protocol (none)

The secure variable inside settings, what parameters can it have?

For google it is: secure = 'tlsv1_2'

But what other options does this variable have?

I have changed the secure = 'tlsv1_2' variable

Now in the Log appears:

* arg: 1
  * nil
* arg: 2
  * string: closed

RESOLVED.

I have configured it with:


port = 587,
    -- enable tls, required for gmail smtp
    secure = 'tlsv1_2',
    starttls = true,
  }


Thank you.