18.10.2016, 20:13
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
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
- -- send an e-mail,
- function mail(to, subject, message)
- -- make sure these settings are correct
- local settings = {
- -- "from" field, only e-mail must be specified here
- from = 'example@gmail.com',
- -- smtp username
- user = 'example@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',
- }
-
- local smtp = require('socket.smtp')
-
- if type(to) ~= 'table' then
- to = { to }
- end
-
- for index, email in ipairs(to) do
- to[ index ] = '<' .. tostring(email) .. '>'
- end
-
- -- message headers and body
- settings.source = smtp.message({
- headers = {
- to = table.concat(to, ', '),
- subject = subject,
- ['Content-type'] = 'text/html; charset=utf-8',
- },
- body = message
- })
-
- -- fixup from field
- settings.from = '<' .. tostring(settings.from) .. '>'
- settings.rcpt = to
-
- return smtp.send(settings)
- end