我使用https://github.com/eleith/emailjs来做node邮件发送的功能。遇到了中文附件名称乱码的问题。 邮件发送部分代码:
server.send({
text: "i hope this works",
from: "sxyx2008[@163](/user/163).com",
to: "sxyx2008[@163](/user/163).com,sxyx2008[@gmail](/user/gmail).com",
cc: "sxyx2008[@gmail](/user/gmail).com",
subject: "testing emailjs",
attachment: [{
data: "<html>i <i>hope</i> this works!<br/>Go语言编程.pdf</html>",
alternative: true
}, {
path: "E:/学习资料/Go语言编程.pdf",
type: "application/pdf",
name: new Buffer("Go语言编程.pdf").toString("utf-8")
}]
}, function(err, message) {
console.log(err || message);
});
控制台log输出:
{ attachments:
[ { path: 'E:/学习资料/Go语言编程.pdf',
type: 'application/pdf',
name: 'Go语言编程.pdf' } ],
alternative:
{ data: '<html>i <i>hope</i> this works!<br/>Go语言编程.pdf</html>',
alternative: true,
charset: 'utf-8',
type: 'text/html',
inline: true },
header:
{ 'message-id': '<1399952046387.0.4252[@acer](/user/acer)>',
date: 'Tue, 13 May 2014 11:34:06 +0800',
from: 'sxyx2008[@163](/user/163).com',
to: 'sxyx2008[@163](/user/163).com,sxyx2008[@gmail](/user/gmail).com',
cc: 'sxyx2008[@gmail](/user/gmail).com',
subject: '=?UTF-8?Q?testing_emailjs?=' },
content: 'text/plain; charset=utf-8',
text: 'i hope this works' }
邮箱中附件显示乱码如下:
Go璇█缂栫▼.pdf
我记得java里面邮件使用base64编码的,这里设置base64不能正常解析。求大神支招,tks!
6 回复