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 settings
#1
Been trying to get the settings correct using my office365 account. 
But i tried changing this script for the FB_mail. This has i guess different settings.
And the secure is different i believe. I think it is TLS1.2 but dont know.
And i am not getting any error in log.

Has anybody had trouble with other email clients. 
Code:
--- [Function] fbe_mail
--- Send email
--- [Comment]
--- This module will sent email if trigger receive value different than 0.  
--- [Input]
--- Trigger [object]
--- To [value, object, storage]
--- Subject [value, object, storage]
--- Message [value, object, storage]
function fbe_mail(input, to, subject, message)
 if (input and input ~= 0) then
          -- 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

 log(smtp.send(settings))
   
 end
end

Tested another script:
-- 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 tls, required for gmail smtp
    secure = 'tlsv1_2',
  }

  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

Now getting this error:

FB Event for 32/1/20 07.05.2019 21:10:01
Library socket/tp:0: attempt to index a nil value
stack traceback:
[C]: in function 'send'
User library FB_Email:52: in function 'fbe_mail'
User script:8: in main chunk
FB Event for 32/1/20 07.05.2019 21:40:31
User script:8: attempt to call global 'fbe_mail' (a nil value)
stack traceback:
User script:8: in main chunk
Reply


Messages In This Thread
Email settings - by Tokatubs - 07.05.2019, 19:23
RE: Email settings - by admin - 08.05.2019, 04:40
RE: Email settings - by Tokatubs - 08.05.2019, 06:02
RE: Email settings - by admin - 08.05.2019, 08:51
RE: Email settings - by Tokatubs - 08.05.2019, 08:54

Forum Jump: