Amit
Amit

Reputation: 3990

nodejs, redis and mailparser wont parse an email

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

Upvotes: 1

Views: 2032

Answers (1)

deepwell
deepwell

Reputation: 20851

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.

Upvotes: 2

Related Questions