Lua eMail语法错误

时间:2014-08-04 14:27:24

标签: email lua

我无法追踪" mail"我的代码块中的函数:

mail(technicalte@gmail.com,testSubject,testMailBody)

我收到以下错误:    第4行的Lua语法错误:&#39;)&#39;预计在&#39; <&#39;

附近

这是什么意思,你能帮帮我吗?

顺便说一句,你可以看到下面的邮件功能:

 function mail(to, subject, message)
  -- make sure these settings are correct
 local settings = {
 -- "from" field, only e-mail must be specified here
 from = 'technicalte@gmail.com',
 -- smtp username
 user = 'technicalte@gmail.com',
 -- smtp password
 password = 'mypassword',
 -- smtp server
 server = 'smtp.gmail.com',
 -- smtp server port
 port = 465,
 -- enable ssl, required for gmail smtp
 secure = 'sslv23',
 }

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

1 个答案:

答案 0 :(得分:1)

mail(technicalte@gmail.com, testSubject, testMailBody)

应该是

mail("technicalte@gmail.com",testSubject,testMailBody)

technicalte@gmail.com不是有效的变量名称。