Logic Machine Forum
Problem : Email with Wiser for KNX - 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: Problem : Email with Wiser for KNX (/showthread.php?tid=4076)



Problem : Email with Wiser for KNX - zuttix - 02.06.2022

Hi ! I'm looking for help regarding an email sending script with a Wiser for KNX.

I already looked into many subjects on this forum but i can't keep send any email with my server.


I link my entire project.

Thanks for the help.


RE: Problem : Email with Wiser for KNX - admin - 02.06.2022

Don't share project files directly as they might contain some sensitive information.
Gmail has recently changed security policy. It requires two-factor authentication so sending from scripts might not possible anymore. You need to use a different e-mail provider.


RE: Problem : Email with Wiser for KNX - legolas2069 - 02.06.2022

Hello admin, could you recommend any alternative to gmail that you know works?

I have a client who wants to use his gmail, but he has two-factor authentication and from what I see it is no longer possible by script.


RE: Problem : Email with Wiser for KNX - admin - 02.06.2022

There are services that can be used for sending only like sendgrid.com (free for low message volumes), but they require a domain name to be attached to the service.
Depending on the task different services can used, for example Telegram is more suitable for notifications than e-mail.


RE: Problem : Email with Wiser for KNX - zuttix - 03.06.2022

(02.06.2022, 08:11)admin Wrote: Don't share project files directly as they might contain some sensitive information.
Gmail has recently changed security policy. It requires two-factor authentication so sending from scripts might not possible anymore. You need to use a different e-mail provider.

Thanks for the tips


Do you have the secure method of outlook ?
Neither of "secure = sslv23" and "secure = STARTLLS" are working and i don't know where to find it :/


RE: Problem : Email with Wiser for KNX - admin - 03.06.2022

STARTTLS uses a different port - most often 587. While standard SSL/TLS uses 465. Also check what the email function returns, it might tell you where the error is:
Code:
res, err = mail(...)
log(res, err)



RE: Problem : Email with Wiser for KNX - zuttix - 03.06.2022

(03.06.2022, 07:28)admin Wrote: STARTTLS uses a different port - most often 587. While standard SSL/TLS uses 465. Also check what the email function returns, it might tell you where the error is:
Code:
res, err = mail(...)
log(res, err)

  Where can i check it ? When i save the script i got 0 error message


RE: Problem : Email with Wiser for KNX - admin - 03.06.2022

Check Logs tab. Only syntax errors are displayed when saving. This error is returned by the mail() function and is not logged anywhere unless you add log() call afterwards.


RE: Problem : Email with Wiser for KNX - zuttix - 03.06.2022

(03.06.2022, 07:36)admin Wrote: Check Logs tab. Only syntax errors are displayed when saving. This error is returned by the mail() function and is not logged anywhere unless you add log() call afterwards.

Alright so i don't have any log error but my mail are not going out.

I got this in mail email.user script : 
    -- smtp server
    server = 'smtp.office365.com',
    -- smtp server port
    port = 587,
    -- enable ssl, required for gmail smtp
    secure = 'STARTTLS'


I think this is working but is there any parameters i need to activate on outlook to make this scrit working ?


RE: Problem : Email with Wiser for KNX - admin - 03.06.2022

You need to manually add log call after sending the e-mail as I've mentioned in the previous post. Without this info there's no way to tell why it's not sending. See point nr.4 here: https://forum.logicmachine.net/showthread.php?tid=2531


RE: Problem : Email with Wiser for KNX - legolas2069 - 03.06.2022

(02.06.2022, 10:10)admin Wrote: There are services that can be used for sending only like sendgrid.com (free for low message volumes), but they require a domain name to be attached to the service.
Depending on the task different services can used, for example Telegram is more suitable for notifications than e-mail.

Thank you, I'll try with a simple gmail account or with telegram.


RE: Problem : Email with Wiser for KNX - christiaens.t - 09.06.2022

Hi,

My gmail scripts suddenly stopped working as well. Apparently google stopped supporting applications that do not provide the required security level as from May 30.
However there's a workaround => enable the 2 step authentication in your google account and then create a specific application password for the app (LogicMachine/W4K) that you want to use without the need for 2-step authentication. Copy the password you created and use this as the password in your lua script in stead of your normal google account password.
This worked for me....

Thijs


RE: Problem : Email with Wiser for KNX - SuperKNX64 - 15.06.2022

(09.06.2022, 20:17)christiaens.t Wrote: Hi,

My gmail scripts suddenly stopped working as well. Apparently google stopped supporting applications that do not provide the required security level as from May 30.
However there's a workaround => enable the 2 step authentication in your google account and then create a specific application password for the app (LogicMachine/W4K) that you want to use without the need for 2-step authentication. Copy the password you created and use this as the password in your lua script in stead of your normal google account password.
This worked for me....

Thijs

Hi,

I have the same issue and I'm glad I could find your answer. However, it does not appear to work for me. Even though I set up a new application password and put it in the email function parameter structure as regular password, I still get the following error:

534-5.7.9 Application-specific password required. Learn more at

534 5.7.9  https://support.google.com/mail/?p=InvalidSecondFactor [...]


Would you mind sharing what you put in the "server", "port" and "secure" fields?
Also, what is supposed to be in the "user" field?

Note that I have managed to send emails through another, less secure provider. I am still willing to use gmail though ; I believe 2 step auth is becoming a standard.


RE: Problem : Email with Wiser for KNX - Dré - 19.06.2022

(09.06.2022, 20:17)christiaens.t Wrote: Hi,

My gmail scripts suddenly stopped working as well. Apparently google stopped supporting applications that do not provide the required security level as from May 30.
However there's a workaround => enable the 2 step authentication in your google account and then create a specific application password for the app (LogicMachine/W4K) that you want to use without the need for 2-step authentication. Copy the password you created and use this as the password in your lua script in stead of your normal google account password.
This worked for me....

Thijs

Thanks, indeed this is working.


(15.06.2022, 12:41)SuperKNX64 Wrote: Hi,

I have the same issue and I'm glad I could find your answer. However, it does not appear to work for me. Even though I set up a new application password and put it in the email function parameter structure as regular password, I still get the following error:

534-5.7.9 Application-specific password required. Learn more at

534 5.7.9  https://support.google.com/mail/?p=InvalidSecondFactor [...]


Would you mind sharing what you put in the "server", "port" and "secure" fields?
Also, what is supposed to be in the "user" field?

Note that I have managed to send emails through another, less secure provider. I am still willing to use gmail though ; I believe 2 step auth is becoming a standard.

this are my settings for google mail;

settings = {
  -- "from" field, only e-mail must be specified here
  from = 'myemailadres@gmail.com',
  -- smtp username
  user = 'myemailadres@gmail.com',
  -- smtp password
  password = 'mypassword',
  -- smtp server
  server = 'smtp.gmail.com',
  -- smtp server port
  port = 465,
  -- enable ssl, required for gmail smtp
  secure = 'sslv23',
}


RE: Problem : Email with Wiser for KNX - SuperKNX64 - 20.06.2022

(19.06.2022, 10:58)Dré Wrote:
(09.06.2022, 20:17)christiaens.t Wrote: Hi,

My gmail scripts suddenly stopped working as well. Apparently google stopped supporting applications that do not provide the required security level as from May 30.
However there's a workaround => enable the 2 step authentication in your google account and then create a specific application password for the app (LogicMachine/W4K) that you want to use without the need for 2-step authentication. Copy the password you created and use this as the password in your lua script in stead of your normal google account password.
This worked for me....

Thijs

Thanks, indeed this is working.


(15.06.2022, 12:41)SuperKNX64 Wrote: Hi,

I have the same issue and I'm glad I could find your answer. However, it does not appear to work for me. Even though I set up a new application password and put it in the email function parameter structure as regular password, I still get the following error:

534-5.7.9 Application-specific password required. Learn more at

534 5.7.9  https://support.google.com/mail/?p=InvalidSecondFactor [...]


Would you mind sharing what you put in the "server", "port" and "secure" fields?
Also, what is supposed to be in the "user" field?

Note that I have managed to send emails through another, less secure provider. I am still willing to use gmail though ; I believe 2 step auth is becoming a standard.

this are my settings for google mail;

settings = {
  -- "from" field, only e-mail must be specified here
  from = 'myemailadres@gmail.com',
  -- smtp username
  user = 'myemailadres@gmail.com',
  -- smtp password
  password = 'mypassword',
  -- smtp server
  server = 'smtp.gmail.com',
  -- smtp server port
  port = 465,
  -- enable ssl, required for gmail smtp
  secure = 'sslv23',
}

Hi Dré,
Thank you so much for providing me with this. However, it does not appear to solve my problem, even using an application password.
Do you believe it might be related to the device's SSL certificate authenticity (self-signed by default I believe) ?


RE: Problem : Email with Wiser for KNX - admin - 20.06.2022

Device certificate is not used for sending e-mails. I've also tried sending through Gmail with App password and it works for me.


RE: Problem : Email with Wiser for KNX - SuperKNX64 - 20.06.2022

Rebooting the device made it work somehow. I can use gmail now. Thank you all for your answers!


RE: Problem : Email with Wiser for KNX - rivieraautomation - 16.07.2023

(20.06.2022, 12:21)Hello everyone. I have a specific demand to have a "From" different for the email. I would like to have a from : Maintenance Company BMS and not an email adress. I have tried but I didnt find solution. Wrote:   -- make sure these settings are correct
 
  ---------------BEGINNING OF USER EDITABLE AREA-------------------
  local settings = {
    -- "from" field, only e-mail must be specified here
    
  from = 'Maintenance Company BMS',
    -- smtp username
    
    user = 'jero*****@gmail.com',
    -- smtp password
    password = 'wrzss****,
    -- smtp server
    server = 'smtp.gmail.com',
    -- smtp server port
    port = 465,
    -- enable ssl, required for gmail smtp
    secure = 'sslv23',
  }
  -------------------END OF USER EDITABLE AREA---------------------

  local smtp = require('socket.smtp')
  local escape = function(v)
    return '<' .. tostring(v) .. '>'
  end

  -- message headers and body
  settings.source = smtp.message({
    headers = {
      to = escape(to),
      subject = subject,
    },
    body = message
  })

  -- fixup from field
settings.from = escape(settings.from)
  settings.rcpt = { escape(to) }

  return smtp.send(settings)
end