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 setting
#15
Hi, 

What is wrong ? 

Code:
-- user function library

function mail(to, subject, message)
  -- make sure these settings are correct
  local settings = {
    -- "from" field, only e-mail must be specified here
    from = 'XXXXXX@XXXXXX.COM',
    -- smtp username
    user = 'XXXXXX@XXXXXX.COM',
    -- smtp password
    password = 'XXXXXX',
    -- smtp server
    server = 'smtp.office365.com',
    -- smtp server port
    port = 587,
    -- enable tls
    secure = 'tlsv1.3',
    -- 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
    
  log("send email:")
  log(settings)
 
  return smtp.send(settings)
 
end
Reply


Messages In This Thread
email setting - by gkentsis - 10.10.2017, 12:00
RE: email setting - by admin - 10.10.2017, 12:24
RE: email setting - by gkentsis - 10.10.2017, 19:16
RE: email setting - by admin - 11.10.2017, 07:59
RE: email setting - by gkentsis - 11.10.2017, 08:51
RE: email setting - by admin - 11.10.2017, 10:27
RE: email setting - by gkentsis - 13.10.2017, 08:12
RE: email setting - by admin - 13.10.2017, 08:45
RE: email setting - by gkentsis - 13.10.2017, 09:06
RE: email setting - by admin - 13.10.2017, 10:02
RE: email setting - by Mrinj - 17.11.2017, 18:43
RE: email setting - by Mrinj - 18.11.2017, 11:45
RE: email setting - by Clémentine - 21.11.2017, 14:36
RE: email setting - by admin - 22.11.2017, 13:00
RE: email setting - by joaodaniel.pereira - 27.03.2024, 09:27
RE: email setting - by admin - 27.03.2024, 09:29
RE: email setting - by joaodaniel.pereira - 27.03.2024, 09:47
RE: email setting - by Daniel - 27.03.2024, 09:50

Forum Jump: