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
#15
(20.08.2020, 10:04)Daniel. Wrote: 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


Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:

Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
  * nil
* arg: 2
  * string: Try again


Using this code in triggered script

Code:
-- make sure mail settings are set in user function library before using this function
Code:
subject = 'Der er kommet post'
Code:
message = 'Med Venlig Hilsen Kastaniely'
Code:
res, err = mail('TSA@InoDes.dk', subject, message)
Code:
log(res, err)
Code:
--mail('TSA@InoDes.dk', subject, message)
Code:
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)

(20.08.2020, 10:19)Tue Wrote:
(20.08.2020, 10:04)Daniel. Wrote: 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


Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:

Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
  * nil
* arg: 2
  * string: Try again


Using this code in triggered script

Code:
-- make sure mail settings are set in user function library before using this function
subject = 'Der er kommet post'
message = 'Med Venlig Hilsen Kastaniely'
res, err = mail('TSA@InoDes.dk', subject, message)
log(res, err)

--mail('TSA@InoDes.dk', subject, message)

POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)

(20.08.2020, 10:19)Tue Wrote:
(20.08.2020, 10:04)Daniel. Wrote: 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


Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:

Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
  * nil
* arg: 2
  * string: Try again


Using this code in triggered script

Code:
-- make sure mail settings are set in user function library before using this function
Code:
subject = 'Der er kommet post'
Code:
message = 'Med Venlig Hilsen Kastaniely'
Code:
res, err = mail('TSA@InoDes.dk', subject, message)
Code:
log(res, err)
Code:
--mail('TSA@InoDes.dk', subject, message)
Code:
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)

(20.08.2020, 10:19)Tue Wrote:
(20.08.2020, 10:04)Daniel. Wrote: 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


Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:

Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
  * nil
* arg: 2
  * string: Try again


Using this code in triggered script

Code:
-- make sure mail settings are set in user function library before using this function
subject = 'Der er kommet post'
message = 'Med Venlig Hilsen Kastaniely'
res, err = mail('TSA@InoDes.dk', subject, message)
log(res, err)

--mail('TSA@InoDes.dk', subject, message)

POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)
Is there anything else in system, I can check (It has newer been able to send Email, have tryeid many times to get it to work). Any port in my Network (IP) that has to be speciel or anything else on server that can block it?
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: