Reputation: 994
I am using the package node-pop3 in my Meteor App. I am successful in RETR command. I get the stream and the info. The info have information only about how many octets.
How can I read the message in email? I am also using mailparser. But I don't know what will I send to mailparser. Is it the whole stream?
Here is the package for mailparser. https://github.com/andris9/mailparser
The problem here is, how can I read email using mailparser? What will I pass to,
mailparser.write(?);
is it the stream?
Upvotes: 1
Views: 1361
Reputation: 11
import * as mailparser from 'mailparser';
import * as PopNode from 'node-pop3';
//--- initialise emailobject:
const pop3Command = new PopNode({
user: 'email address',
password: 'password',
host: 'hostname'
});
let emailsList = await pop3Command.UIDL(); // fetch list of all emails
let msg = await pop3Command.RETR(msgNumber); // fetch the email content
let parsedEmail = await simpleParser(msg); // convert into readable email content
Upvotes: 1
Reputation: 3
Things probably have changed since this question was posted, but at least as of version 0.8.0, node-pop3's RETR returns a string (using a nice helper function in that package called stream2String). That string can be passed to simpleParser to get the parsed contents.
import {simpleParser} from 'mailparser';
let msg = await pop3Command.RETR(msgNumber);
let parsedEmail = await simpleParser(msg);
Upvotes: 0