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.

Problem : Email with Wiser for KNX
#1
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.
Reply
#2
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.
Reply
#3
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.
Reply
#4
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.
Reply
#5
(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 :/
Reply
#6
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)
Reply
#7
(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
Reply
#8
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.
Reply
#9
(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 ?
Reply
#10
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
Reply
#11
(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.
Reply
#12
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
Reply
#13
(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.
Reply
#14
(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',
}
Reply
#15
(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) ?
Reply
#16
Device certificate is not used for sending e-mails. I've also tried sending through Gmail with App password and it works for me.
Reply
#17
Rebooting the device made it work somehow. I can use gmail now. Thank you all for your answers!
Reply
#18
(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
Reply


Forum Jump: