2
我有以下代码:我如何使用lua socket/smtp发送附件?
local email_credentials = function(email_address, password, username)
local from
local contents = read_email_contents_file()
contents= string.gsub(contents, "<<password>>", password)
from = "<[email protected]>"
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"
,现在我得到一个附件。但是,数据全是混乱的。看起来是这样的:
该文件的内容是文本。 ... 谢谢
您是否真的在base64中编码过“内容”? – Ignacio 2013-03-08 00:32:13