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.

Scripting
#1
Hello

I have used the scripts below and I have also turned off the 2 step verification in google account 

function Email(to, subject, message)
  -- make sure these settings are correct

  ---------------BEGINNING OF USER EDITABLE AREA-------------------
  local settings = {
    -- "from" field, only e-mail must be specified here
        from = 'XXXXXX@gmail.com',
    -- smtp username
    user = 'XXXXXX@gmail.com',
    -- smtp password
    password = 'XXXXXXX',
    -- smtp server
    server = 'smtp.gmail.com',
    -- smtp server port
    port = 465,
    -- enable ssl, required for gmail smtp
    secure = 'tlsv1_2',
  }
  -------------------END OF USER EDITABLE AREA---------------------

  local smtp = require('socket.smtp')
  local escape = function(v)
    return '<' .. tostring(v) .. '>'
  end

  -- message headers and body
  settings.source = smtp.message({
    headers = {
      to = escape(to),
      subject = subject,
    },
    body = message
  })

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

  return smtp.send(settings)
end




require('user.Email')

Email("XXXXXX@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
Email("DDDDDD@gmail.com", "Alarm", "Παραβίαση Σπιτιού")
log(mail("XXXXXX@gmail.com") )



it can't send an email and I have the error below

User script 5: attempt to call global 'mail' (a nil value)
stack traceback

er
Reply


Messages In This Thread
Scripting - by XSPA2474KW - 09.06.2022, 06:59
RE: Scripting - by admin - 09.06.2022, 07:04
RE: Scripting - by XSPA2474KW - 09.06.2022, 13:28
RE: Scripting - by admin - 09.06.2022, 14:34
RE: Scripting - by XSPA2474KW - 09.06.2022, 16:03
RE: Scripting - by admin - 09.06.2022, 16:12
RE: Scripting - by XSPA2474KW - 09.06.2022, 16:19
RE: Scripting - by admin - 09.06.2022, 16:21
RE: Scripting - by XSPA2474KW - 09.06.2022, 16:31
RE: Scripting - by XSPA2474KW - 10.06.2022, 06:07
RE: Scripting - by Daniel - 10.06.2022, 07:23
RE: Scripting - by Daniel - 10.06.2022, 07:24

Forum Jump: