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 sending do not work
#14
Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:
-- 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
------------------------------
Ctrl+F5
Reply


Messages In This Thread
Email sending do not work - by Tue - 20.08.2020, 09:34
RE: Email sending do not work - by admin - 20.08.2020, 09:35
RE: Email sending do not work - by Tue - 20.08.2020, 09:38
RE: Email sending do not work - by admin - 20.08.2020, 09:38
RE: Email sending do not work - by Tue - 20.08.2020, 09:41
RE: Email sending do not work - by admin - 20.08.2020, 09:42
RE: Email sending do not work - by Tue - 20.08.2020, 09:44
RE: Email sending do not work - by admin - 20.08.2020, 09:49
RE: Email sending do not work - by Tue - 20.08.2020, 09:51
RE: Email sending do not work - by Tue - 20.08.2020, 09:55
RE: Email sending do not work - by Daniel - 20.08.2020, 09:58
RE: Email sending do not work - by Tue - 20.08.2020, 09:58
RE: Email sending do not work - by Daniel - 20.08.2020, 10:04
RE: Email sending do not work - by Tue - 20.08.2020, 10:19
RE: Email sending do not work - by admin - 20.08.2020, 10:29
RE: Email sending do not work - by Tue - 20.08.2020, 10:37
RE: Email sending do not work - by Ibrahim - 20.11.2020, 15:50
RE: Email sending do not work - by Daniel - 23.11.2020, 09:55
RE: Email sending do not work - by Ibrahim - 23.11.2020, 15:44
RE: Email sending do not work - by Ibrahim - 26.11.2020, 08:04
RE: Email sending do not work - by admin - 27.11.2020, 08:27
RE: Email sending do not work - by Ibrahim - 27.11.2020, 12:39
RE: Email sending do not work - by admin - 27.11.2020, 14:43
RE: Email sending do not work - by Ibrahim - 27.11.2020, 20:13
RE: Email sending do not work - by admin - 30.11.2020, 07:35
RE: Email sending do not work - by BrentW - 24.03.2021, 00:15
RE: Email sending do not work - by admin - 24.03.2021, 09:22
RE: Email sending do not work - by BrentW - 25.03.2021, 02:32
RE: Email sending do not work - by admin - 25.03.2021, 07:14
RE: Email sending do not work - by BrentW - 06.04.2021, 04:14
RE: Email sending do not work - by admin - 06.04.2021, 05:48

Forum Jump: