Skip to content

transitive-bullshit/parse-email

Repository files navigation

parse-email

Parses mime-encoded email messages.

NPM Build Status JavaScript Style Guide

Install

npm install --save parse-email

Usage

const parse = require('parse-email') const fs = require('fs') const input = fs.readFileSync('./fixtures/0.txt', 'utf8') parse(input) .then((email) => { console.log(email) })

Example parsed output:

{ "attachments": [ ... ], "headers": { ... }, "html": "<!DOCTYPE html>\n<html>...</html>", "text": "...", "textAsHtml": "<p>...</p>", "subject": "Example email subject", "date": "2018-05-09T14:17:02.000Z", "to": { "value": [ { "address": "fischxxxx@gmail.com", "name": "Travis Fischer" } ], "html": "<span class=\"mp_address_name\">Travis Fischer</span> &lt;<a href=\"mailto:fischxxxx@gmail.com\" class=\"mp_address_email\">fischxxxx@gmail.com</a>&gt;", "text": "Travis Fischer <fischxxxx@gmail.com>" }, "from": { "value": [ { "address": "courses-xxxxxx@theblockchainacademy.com", "name": "Bryant Nielson" } ], "html": "<span class=\"mp_address_name\">Bryant Nielson</span> &lt;<a href=\"mailto:courses-xxxxxx@theblockchainacademy.com\" class=\"mp_address_email\">courses-xxxxxx@theblockchainacademy.com</a>&gt;", "text": "Bryant Nielson <courses-xxxxxx@theblockchainacademy.com>" }, "messageId": "<01.B3.11399.xxxxxxxx@momentum1-mta1>" }

API

parse(input)

Returns: Promise<Object>

Parses the given input string as a mime-encoded email.

input

Type: String Required

Mime-encoded email string to parse.

Related

License

Note: this module relies on @nodemailer/mailparser2 which has a more restrictive license.

MIT © Travis Fischer

Support my OSS work by following me on twitter twitter

About

Parses mime-encoded email messages.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published