我有以下代码:
local email_credentials = function(email_address, password, username)
local from
local contents = read_email_contents_file()
contents= string.gsub(contents, "<<password>>", password)
from = "<CAdmin@test.net>"
rcpt = {
"<"..email_address..">"
}
mesgt = {
headers = {
to = email_address,
["content-type"] = 'text/html',
subject = "Your Password"
},
body = contents
}
r, e = smtp.send{
from = from,
rcpt = rcpt,
server = 'localhost',
source = smtp.message(mesgt)
}
end
找到这个帖子:
http://lua-users.org/lists/lua-l/2005-08/msg00021.html
我尝试将标题部分更改为:
headers = {
to = email_address,
["content-type"] = 'text/html',
["content-disposition"] = 'attachment; filename="/var/log/test.log"',
subject = "test email with attachment"
},
但这没有用。发送/接收但没有附件的电子邮件。
任何帮助,将不胜感激。
谢谢
编辑 1
我添加了以下两行:
["content-description"] ='test description',
["content-transfer-encoding"] = "BASE64"
现在我得到一个附件。然而,所有的数据都是杂乱无章的。看起来像这样:
=«,ŠÝrm/'LŒq©ÚuÜ!jׯz»^ÆÜÁ©í¶‹aŠÇ¦j)
文件的内容只是文本....谢谢