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.

export csv
#10
1. Admin does not work. I also tried to change the security settings ("sslv23", "tlsv1", "tlsv11" or "tlsv12")
Using 25 port without security settings, everything works!

2. Why does this script send two emails?

-- send an e-mail with attachment
function mailattach(to, subject, message, filename, filedata, mimetype)
-- make sure these settings are correct
local settings = {
-- "from" field, only e-mail must be specified here
from = 'user@domen.com',
-- smtp server
server = 'mail.apollo.lv',
-- smtp server port
port = 25,


}

  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

  -- escape double quotes in file name
  filename = filename:gsub('"', '\\"')

  -- message headers and body
  settings.source = smtp.message({
    headers = {
      to = table.concat(to, ', '),
      subject = subject,
    },
    body = {
      {
        headers = {
          ['Content-Type'] = 'text/html; charset=utf-8',
        },
        body = mime.eol(0, message)
      },
      {
        headers = {
          ['Content-Type'] = mimetype or 'text/plain',
          ['Content-Disposition'] = 'attachment; filename="' .. filename .. '"',
          ['Content-Transfer-Encoding'] = 'BASE64',
        },
        body = ltn12.source.chain(
          ltn12.source.string(filedata),
          ltn12.filter.chain(mime.encode('base64'), mime.wrap())
        )
      }
    }
  })

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

  return smtp.send(settings)
end
Reply


Messages In This Thread
export csv - by akn - 07.04.2017, 09:11
RE: export csv - by buuuudzik - 07.04.2017, 10:16
RE: export csv - by admin - 07.04.2017, 11:25
RE: export csv - by buuuudzik - 07.04.2017, 14:28
RE: export csv - by akn - 10.04.2017, 16:42
RE: export csv - by akn - 10.04.2017, 18:06
RE: export csv - by Erwin van der Zwart - 10.04.2017, 19:39
RE: export csv - by akn - 11.04.2017, 12:15
RE: export csv - by admin - 11.04.2017, 12:21
RE: export csv - by akn - 11.04.2017, 20:41
RE: export csv - by admin - 19.04.2017, 12:29
RE: export csv - by akn - 22.04.2017, 13:28
RE: export csv - by Erwin van der Zwart - 22.04.2017, 18:35
RE: export csv - by akn - 24.04.2017, 19:27
RE: export csv - by Erwin van der Zwart - 24.04.2017, 21:37
RE: export csv - by akn - 26.04.2017, 14:28
RE: export csv - by akn - 22.08.2017, 11:02
RE: export csv - by admin - 24.08.2017, 10:05
RE: export csv - by akn - 25.08.2017, 12:50

Forum Jump: