You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mailparser has a bug and skip the html content sometimes, apparently this is due to excess space. I tried to debug without success.
constassert=require("assert");constfs=require("fs");constMailComposer=require("nodemailer/lib/mail-composer");constnodemailerOpenpgp=require("nodemailer-openpgp");constopenpgp=require("openpgp");const{simpleParser}=require('mailparser');for(constattachmentsof[[],[{filename: 'text1.txt',content: 'hello world!'}]]){console.log("try with",attachments,"attachments");constmail=newMailComposer({from: "from@localhost.com",to: "to@localhost.com",subject: "subject",html: "<p>Hello</p>",
attachments
});mail['compile']()['build'](async(err,message)=>{constsigner=newnodemailerOpenpgp.Encrypter({encryptionKeys: [fs.readFileSync('./pgp-public.pem','utf8')],signingKey: fs.readFileSync('./pgp-private.pem','utf8'),passphrase: 'super long and hard to guess secret'});constchunks=[];signer.on('data',chunk=>chunks.push(chunk));signer.on('end',async()=>{const{data: decrypted}=awaitopenpgp.decrypt({message: awaitopenpgp.readMessage({armoredMessage: Buffer.concat(chunks).toString('utf-8')}),decryptionKeys: awaitopenpgp.decryptKey({privateKey: awaitopenpgp.readPrivateKey({armoredKey: fs.readFileSync('./pgp-private.pem','utf8')}),passphrase: "super long and hard to guess secret"})});// parse without pgpparse(message);// worksparse(decrypted.replace(' \n\n ','\n\n'));parse(decrypted.replace('\n\n ','\n\n'));// parse decrypted message doesn't work due to 2 spaces on the first line' \n\n '// "Content-Type: multipart/mixed; boundary=\"--_NmP-f651c6a9483b6a0f-Part_1\" \n\n ----_NmP-f651c6a9483b6a0f-Part_1\nContent-Type: text/html; charset=utf-8\nContent-Transfer-Encoding: 7bit\n\n<p>Hello</p>\n----_NmP-f651c6a9483b6a0f-Part_1\nContent-Type: text/plain; name=text1.txt\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; filename=text1.txt\n\naGVsbG8gd29ybGQh\n----_NmP-f651c6a9483b6a0f-Part_1--\n"parse(decrypted);});signer.end(message);});functionparse(message){simpleParser(message,{},(err,parsed)=>{if(attachments.length){assert.strictEqual(parsed.attachments.length,1);assert.strictEqual(parsed.attachments[0].filename,'text1.txt');}assert.strictEqual(parsed.html!==false,true);});}}
The text was updated successfully, but these errors were encountered:
Hello,
The mailparser has a bug and skip the html content sometimes, apparently this is due to excess space. I tried to debug without success.
The text was updated successfully, but these errors were encountered: