andris9/mailparser — pull request #23 by jackyz (2011-11-24 05:10:59+00:00)
Title: make parseBody could handle feed data like a single "\r\n".

I'm using mailparser with smtp (https://github.com/aredridel/node-smtp) as a incoming email server just like this

```javascript
var smtp = require('smtp');

smtp.createServer(function(connection) {
connection.on('DATA', function(message) {
var MailParser = require('mailparser').MailParser;
var mp = new MailParser();
mp.on("body", function(body){
console.log("!!! body");
});
message.on('data', function(data) {
mp.feed(data);
});
message.on('end', function() {
mp.end();
message.accept()
});
});
}).listen(25);

console.log("SMTP server running on port 25");
````

But it doesn't work like I expected.

The reason is smtp will fire `data` event each line of the incoming mail. So this line `data.indexOf("\r\n\r\n", pos)` will never match, because the value of data could be `"\r\n"`. I just add some code to handle that case.