nodejs, redis and mailparser wont parse an email

2k views Asked by At

I am using mailparser by andris(https://github.com/andris9/mailparser). I am sending an email via redis to an nodejs app. The mailparser for somereason is unable to parse it. What could be causing the issue?

The code to get the email from redis. client is an instance of node_redis Client. MailParser is andris' mailparser. The email in redis is sent via another server, to whose channel i have subscribed. The email sent, when saved in a text file and parsed using andris' test.js, gives the expected output.

client.subscribe('email1');

client.on('message', function(channel, message){
    var Parser = new MailParser();
    Parser.on('headers', function(headers){
        console.log(headers.addressesTo[0].address);
    });
    Parser.feed(message);
    Parser.end();
});

I found the reason for this. The input I saw receiving had \r\n converted to \n

1

There are 1 answers

0
deepwell On

Instead of

 Parser.feed(message);

I believe you want

Parser.write(message);

I couldn't find the feed method in the documentation. I am using the write function and it's working. The message is the original unaltered email message, including headers, body, and attachments.