因此,我尝试使用带有 ssl 的 luasocket smtp 函数发送电子邮件,但由于某种原因,我收到此错误/usr/local/share/lua/5.1/socket/smtp.lua:80: attempt to call field 'b64' (a nil value)
,我已下载所有库,但我不知道为什么它不起作用。这是我的代码
local smtp = require("socket.smtp")
local ssl = require('ssl')
local https = require 'ssl.https'
local mime = require("mime")
function sslCreate()
local sock = socket.tcp()
return setmetatable({
connect = function(_, host, port)
local r, e = sock:connect(host, port)
if not r then return r, e end
sock = ssl.wrap(sock, {mode='client', protocol='tlsv1'})
return sock:dohandshake()
end
}, {
__index = function(t,n)
return function(_, ...)
return sock[n](sock, ...)
end
end
})
end
local k, e = smtp.send{
from = "[REDACTED]",
rcpt = self.params.email,
user = "[REDACTED]",
password = "[REDACTED]",
port = 465,
server = "smtp.gmail.com",
source = smtp.message(message),
create = sslCreate
}
if not k then
print(e)
end