parse-email
v1.0.0
Published
Parses mime-encoded email messages.
Downloads
1,247
Readme
parse-email
Parses mime-encoded email messages.
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": "[email protected]",
"name": "Travis Fischer"
}
],
"html": "<span class=\"mp_address_name\">Travis Fischer</span> <<a href=\"mailto:[email protected]\" class=\"mp_address_email\">[email protected]</a>>",
"text": "Travis Fischer <[email protected]>"
},
"from": {
"value": [
{
"address": "[email protected]",
"name": "Bryant Nielson"
}
],
"html": "<span class=\"mp_address_name\">Bryant Nielson</span> <<a href=\"mailto:[email protected]\" class=\"mp_address_email\">[email protected]</a>>",
"text": "Bryant Nielson <[email protected]>"
},
"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
- @nodemailer/mailparser2 - Mail parser used under the hood.
- @nodemailer/mailparser - Deprecated mail parser.
- emailjs-mime-parser - Parse a mime tree, no magic included.
- nylas-mail - An extensible desktop mail app built on the modern web.
License
Note: this module relies on @nodemailer/mailparser2 which has a more restrictive license.
MIT © Travis Fischer