lib/index.js
function buildEmail(envelope, data) {
  return simpleParser(data)
    .then(function(parsedEmail) {
      const sender    = envelope.mailFrom.address;
      const receivers = envelope.rcptTo
        .map(recipient => [ recipient.address, true ])
        .reduce(tupleToObject, {});

      const headers   = [ ... parsedEmail.headers ]
        .map(readHeader)
        .reduce(tupleToObject, {});

      const email     = {
        sender,
        receivers,
        data,
        headers,
        body:      parsedEmail.text,
        html:      parsedEmail.html,
        attachments:      parsedEmail.attachments
      };

      return email;
    });
}
function buildEmail(envelope, data) {
  return simpleParser(data)
    .then(function(parsedEmail) {
      const sender    = envelope.mailFrom.address;
      const receivers = envelope.rcptTo
        .map(recipient => [ recipient.address, true ])
        .reduce(tupleToObject, {});

      const headers   = [ ... parsedEmail.headers ]
        .map(readHeader)
        .reduce(tupleToObject, {});

      const email     = {
        sender,
        receivers,
        data,
        headers,
        body:      parsedEmail.text,
        html:      parsedEmail.html,
        attachments:      parsedEmail.attachments
      };

      return email;
    });
}
function buildEmail ( envelope , data ) { return simpleParser ( data ) . then ( function ( parsedEmail ) { const sender = envelope . mailFrom . address ; const receivers = envelope . rcptTo . map ( recipient => [ recipient . address , true ] ) . reduce ( tupleToObject , { } ) ; const headers = [ ... parsedEmail . headers ] . map ( readHeader ) . reduce ( tupleToObject , { } ) ; const email = { sender , receivers , data , headers , body : parsedEmail . text , html : parsedEmail . html , attachments : parsedEmail . attachments } ; return email ; } ) ; }
Resolves to the email object handlers receive.
Resolves to the email object handlers receive .