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.

Attempt to index a nil value when sending email with lua
#1
I'm trying to send an email in lua with slightly modified code from documentation:
Code:
function mail(to, subject, message)
  -- SMTP settings
  local settings = {
    from = 'mail@example.com',
    user = 'mail@example.com',
    password = 'password',
    server = 'smtp.office365.com',
    port = XYZ,
    secure = 'starttls',
  }

  local smtp = require('socket.smtp')

  -- message headers and body
  settings.source = smtp.message({
    headers = {
      to = escape(to),
      subject = subject,
      ['Content-type'] = 'text/html; charset=utf-8',
    },
    body = message
  })

  -- fixup from field
  settings.from = escape(settings.from)
  settings.rcpt = { escape(to) }

  return smtp.send(settings)
end

Even if I use the original documentation code I get an error:
Code:
Error in /usr/lib/lua/socket/tp.lua at line 0: attempt to index a nil value

I did not create tp.lua and unfortunately when I try to open it I get this:
Quote:The file is not displayed in the editor because it is either binary or uses an unspupported text encoding.
Reply
#2
Does it have Keep source unselected?
------------------------------
Ctrl+F5
Reply
#3
Are you asking if I have it in Scripting > User Libraries ? Like those:
[Image: FELDp4R.png]
No, I don't, these are all that are there and all of them have keep source checked.
Reply
#4
OK, this is internal library. This is question to admin then.
------------------------------
Ctrl+F5
Reply
#5
Can you send access details via PM so I can check locally?
Reply


Forum Jump: