From 64740b812e887a4f1548103f07233ccb06dfcdb3 Mon Sep 17 00:00:00 2001 From: Cloud Date: Thu, 19 Sep 2019 17:07:49 +0800 Subject: [PATCH] fix: mail some content garbled (#3112) --- lib/routes/mail/imap.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/routes/mail/imap.js b/lib/routes/mail/imap.js index 32840424a..c440cbbb5 100644 --- a/lib/routes/mail/imap.js +++ b/lib/routes/mail/imap.js @@ -2,7 +2,6 @@ const ImapClient = require('emailjs-imap-client').default; const queryString = require('query-string'); const config = require('@/config'); const parser = require('mailparser').simpleParser; -const iconv = require('iconv-lite'); module.exports = async (ctx) => { const email = ctx.params.email; @@ -39,7 +38,7 @@ module.exports = async (ctx) => { }); const ParserMail = async (data) => { - const mail = await parser(data); + const mail = await parser(Buffer.from(data, 'binary')); let content = mail.html || mail.textAsHtml; if (mail.attachments.length > 0) { content += `

附件(${mail.attachments.length})

`; @@ -57,7 +56,7 @@ module.exports = async (ctx) => { if (cache) { return Promise.resolve(JSON.parse(cache)); } - const description = await ParserMail(iconv.decode(item['body[]'], 'utf8')); + const description = await ParserMail(item['body[]']); const single = { title: item.envelope.subject, description,