function main()
local smtp = require("socket.smtp")
local mime = require("mime")
local ltn12 = require("ltn12")
local f = "/var/touchelf/img.png"
snapshotScreen(f)
mesgt = smtp.message{
headers = {
to = "54321@qq.com", --收件人
subject = "邮件标题"
},
body = {
[1] = {
body = mime.eol(0, "邮件正文")
},
[2] = {
headers = {
["content-type"] = 'text/plain; name="img.png"',
["content-disposition"] = 'attachment; filename="img.png"',
["content-description"] = 'the send script\'s source',
["content-transfer-encoding"] = "BASE64"
},
body = ltn12.source.chain(
ltn12.source.file(io.open(f, "r")),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
},
}
}
r,e = smtp.send{
server = "smtp.qq.com", --邮箱服务器
user = "12345@qq.com", --用户名
password = "password", --密码或授权码
from = "<12345@qq.com>", --发件人
rcpt = { --发送列表
"<12345@qq.com>"
},
source = mesgt --发送内容
}
if r then
logDebug("ok")
else
logDebug(e)
end
end
如果一次发送多个图片拷贝body下的[2]内容,添加[3],[4]即可.望采纳