email setting
#1
Hi

our smtp server needs to enable tls. what is the right parameter for secure?

   

txs
Reply
#2
Put tlsv12 there, but in most cases port 587 uses STARTTLS mode, so you need to install updated LuaSocket package. Which hardware are you using?
Reply
#3
(10.10.2017, 12:24)admin Wrote: Put tlsv12 there, but in most cases port 587 uses STARTTLS mode, so you need to install updated LuaSocket package. Which hardware are you using?

I have 1 LM4 

   

and 1 LM5 

   

with last firmware and with luashocket 2.0.2-17 both. 
My smtp server setting are

   

So do i need to install LuaSocket package?
Reply
#4
Update package from System config-> System > Packages > Click (+) icon

Package for LM4:
http://dl.openrb.com/lm-17/pkg/luasocket...23_mxs.ipk

Package for LM5:
http://dl.openrb.com/lm-17-imx6/pkg/luas...3_imx6.ipk

First try with secure = 'starttls',
If it does not work then try secure = 'tlsv12',
In your script put mail function call inside log( ) so you can see an error message in logs if there is any.
Reply
#5
(11.10.2017, 07:59)admin Wrote: Update package from System config-> System > Packages > Click (+) icon

Package for LM4:
http://dl.openrb.com/lm-17/pkg/luasocket...22_mxs.ipk

Package for LM5:
http://dl.openrb.com/lm-17-imx6/pkg/luas...2_imx6.ipk

First try with secure = 'starttls',
If it does not work then try secure = 'tlsv12',
In your script put mail function call inside log( ) so you can see an error message in logs if there is any.

hi

with secure = 'starttls' email() returns

* arg: 1
 * nil
* arg: 2
 * nil


 and with secure = 'tlsv12'

* arg: 1
 * nil
* arg: 2
 * string: closed
Reply
#6
Can you send login/password that your are using via PM so I can check it locally?
Reply
#7
(11.10.2017, 10:27)admin Wrote: Can you send login/password that your are using via PM so I can check it locally?

sent it
Reply
#8
Thanks, please update packages again:
Package for LM4:
http://dl.openrb.com/lm-17/pkg/luasocket...23_mxs.ipk
Package for LM5:
http://dl.openrb.com/lm-17-imx6/pkg/luas...3_imx6.ipk

Replace mail() function in Common functions with this and change from/user/password field values to your access details:
Code:
function mail(to, subject, message)
  -- make sure these settings are correct
  local settings = {
    -- "from" field, only e-mail must be specified here
    from = '...',
    -- smtp username
    user = '...',
    -- smtp password
    password = '...',
    -- smtp server
    server = 'mailgate.cosmotemail.gr',
    -- smtp server port
    port = 587,
    -- enable tls
    secure = 'tlsv1',
    -- use STARTTLS mode
    starttls = true,
  }

  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

  -- fixup from field
  local from = '<' .. tostring(settings.from) .. '>'

  -- message headers and body
  settings.source = smtp.message({
    headers = {
      to = table.concat(to, ', '),
      subject = subject,
      ['From'] = from,
      ['Content-type'] = 'text/html; charset=utf-8',
    },
    body = message
  })

  settings.from = from
  settings.rcpt = to

  return smtp.send(settings)
end
Reply
#9
(13.10.2017, 08:45)admin Wrote: Thanks, please update packages again:
Package for LM4:
http://dl.openrb.com/lm-17/pkg/luasocket...23_mxs.ipk
Package for LM5:
http://dl.openrb.com/lm-17-imx6/pkg/luas...3_imx6.ipk

Replace mail() function in Common functions with this and change from/user/password field values to your access details:
Code:
function mail(to, subject, message)
 -- make sure these settings are correct
 local settings = {
   -- "from" field, only e-mail must be specified here
   from = '...',
   -- smtp username
   user = '...',
   -- smtp password
   password = '...',
   -- smtp server
   server = 'mailgate.cosmotemail.gr',
   -- smtp server port
   port = 587,
   -- enable tls
   secure = 'tlsv1',
   -- use STARTTLS mode
   starttls = true,
 }

 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

 -- fixup from field
 local from = '<' .. tostring(settings.from) .. '>'

 -- message headers and body
 settings.source = smtp.message({
   headers = {
     to = table.concat(to, ', '),
     subject = subject,
     ['From'] = from,
     ['Content-type'] = 'text/html; charset=utf-8',
   },
   body = message
 })

 settings.from = from
 settings.rcpt = to

 return smtp.send(settings)
end

it works perfect. Thank you very much
Can you send me the package for LogicMachine5 Lite Power?
Reply
#10
It's already there:
http://dl.openrb.com/lm-17-imx6/pkg/luas...3_imx6.ipk
Reply


Forum Jump: