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 notification
#3
Hi
Yesterday i programmed the email notification from www.openrb.com examples. I tried to update to latest version on my LM now and the mail sending doesnt work anymore. How do I fix it?
I am using the code underneath and have made the gmail account allow unsure apps.


event based
mail('exampe@gmail.com', 'Alert', 'KNX object 1/2/2 value is')


common functions

  1. -- send an e-mail,
  2. function mail(to, subject, message)
  3.  -- make sure these settings are correct
  4.  local settings = {
  5.    -- "from" field, only e-mail must be specified here
  6.    from = 'example@gmail.com',
  7.    -- smtp username
  8.    user = 'example@gmail.com',
  9.    -- smtp password
  10.    password = 'mypassword',
  11.    -- smtp server
  12.    server = 'smtp.gmail.com',
  13.    -- smtp server port
  14.    port = 465,
  15.    -- enable ssl, required for gmail smtp
  16.    secure = 'sslv23',
  17.  }
  18.  
  19.  local smtp = require('socket.smtp')
  20.  
  21.  if type(to) ~= 'table' then
  22.    to = { to }
  23.  end
  24.  
  25.  for index, email in ipairs(to) do
  26.    to[ index ] = '<' .. tostring(email) .. '>'
  27.  end
  28.  
  29.  -- message headers and body
  30.  settings.source = smtp.message({
  31.    headers = {
  32.      to = table.concat(to, ', '),
  33.      subject = subject,
  34.      ['Content-type'] = 'text/html; charset=utf-8',
  35.    },
  36.    body = message
  37.  })
  38.  
  39.  -- fixup from field
  40.  settings.from = '<' .. tostring(settings.from) .. '>'
  41.  settings.rcpt = to
  42.  
  43.  return smtp.send(settings)
  44. end
Reply


Messages In This Thread
email notification - by Peter - 22.02.2016, 17:55
RE: email notification - by admin - 23.02.2016, 07:56
RE: email notification - by PassivPluss - 18.10.2016, 20:13
RE: email notification - by PassivPluss - 26.10.2016, 20:44
RE: email notification - by admin - 27.10.2016, 07:16
RE: email notification - by AEK - 27.10.2016, 07:43
RE: email notification - by buuuudzik - 27.10.2016, 16:33
RE: email notification - by admin - 27.10.2016, 18:02
RE: email notification - by buuuudzik - 27.10.2016, 18:03
RE: email notification - by admin - 27.10.2016, 18:15
RE: email notification - by buuuudzik - 27.10.2016, 21:12
RE: email notification - by admin - 28.10.2016, 06:42
RE: email notification - by buuuudzik - 28.10.2016, 06:55
RE: email notification - by PassivPluss - 30.10.2016, 06:04

Forum Jump: