https://github.com/transitive-bullshit/parse-email
Parses mime-encoded email messages.
https://github.com/transitive-bullshit/parse-email
email email-parser email-parsing mail mime multipart parser
Last synced: 27 days ago
JSON representation
Parses mime-encoded email messages.
- Host: GitHub
- URL: https://github.com/transitive-bullshit/parse-email
- Owner: transitive-bullshit
- Created: 2018-05-09T18:46:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T05:37:52.000Z (over 3 years ago)
- Last Synced: 2024-10-20T01:08:35.254Z (8 months ago)
- Topics: email, email-parser, email-parsing, mail, mime, multipart, parser
- Language: JavaScript
- Size: 439 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# parse-email
> Parses mime-encoded email messages.
[](https://www.npmjs.com/package/parse-email) [](https://travis-ci.com/transitive-bullshit/parse-email) [](https://standardjs.com)
## Install
```bash
npm install --save parse-email
```## Usage
```js
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:
```json
{
"attachments": [ ... ],
"headers": { ... },
"html": "\n...",
"text": "...",
"textAsHtml": "...
",
"subject": "Example email subject",
"date": "2018-05-09T14:17:02.000Z",
"to": {
"value": [
{
"address": "[email protected]",
"name": "Travis Fischer"
}
],
"html": "Travis Fischer <[email protected]>",
"text": "Travis Fischer "
},
"from": {
"value": [
{
"address": "[email protected]",
"name": "Bryant Nielson"
}
],
"html": "Bryant Nielson <[email protected]>",
"text": "Bryant Nielson "
},
"messageId": "<01.B3.11399.xxxxxxxx@momentum1-mta1>"
}
```## API
### parse(input)
Returns: `Promise`
Parses the given input string as a mime-encoded email.
#### input
Type: `String`
**Required**Mime-encoded email string to parse.
## Related
- [@nodemailer/mailparser2](https://yarnpkg.com/en/package/@nodemailer/mailparser2) - Mail parser used under the hood.
- [@nodemailer/mailparser](https://github.com/nodemailer/mailparser) - Deprecated mail parser.
- [emailjs-mime-parser](https://github.com/emailjs/emailjs-mime-parser) - Parse a mime tree, no magic included.
- [nylas-mail](https://github.com/nylas/nylas-mail) - An extensible desktop mail app built on the modern web.## License
Note: this module relies on [@nodemailer/mailparser2](https://yarnpkg.com/en/package/@nodemailer/mailparser2) which has a more restrictive license.
MIT © [Travis Fischer](https://github.com/transitive-bullshit)
Support my OSS work by following me on twitter
![]()