nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

How to save the email riceived? #133

Closed realtebo closed 4 years ago

realtebo commented 4 years ago

I see that using this code I can output stream to video

onData(stream, session, callback) {
    stream.pipe(process.stdout); // print message to console
    stream.on("end", callback);
  }

But, how can I SAVE received stream? How can I capture all the stream into a variable, for example?

xdevnull commented 4 years ago

You need to parse the stream You can use SimpleParser.

https://github.com/nodemailer/mailparser

onData(stream, session, callback) {
    simpleParser(stream, (err, parsed) => {
        // store 
    });
  }