fix: mail some content garbled (#3112)
This commit is contained in:
@@ -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 += `<h3>附件(${mail.attachments.length})</h3>`;
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user