simpleimfparser 0.0.2
Install from the command line:
Learn more about npm packages
$ npm install @carlgo11/simpleimfparser@0.0.2
Install via package.json:
"@carlgo11/simpleimfparser": "0.0.2"
About this version
A TypeScript library for parsing Internet Message Format (IMF) emails, extracting headers, envelope details, and message bodies while providing useful utilities for email manipulation.
- Parses raw IMF emails from string or stream input
- Supports header parsing (including multi-line folding)
- Provides a structured Email class with helper functions:
-
getHeader(name)
– Retrieve a header -
addHeader(name, value)
– Add a new header -
removeHeader(name)
– Remove a header -
getBody()
– Get the email body
-
- Handles multiple headers with the same name (e.g.,
Received
headers) - Supports UTF-8 names & addresses (RFC 6532)
npm install @carlgo11/simpleimfparser
import parseEmail from '@carlgo11/simpleimfparser';
import fs from 'fs';
(async () => {
const rawData = fs.readFileSync('test-email.eml', 'utf-8');
const envelope = {
from: '[email protected]',
to: ['[email protected]'],
senderIP: '192.168.1.1'
};
const email = await parseEmail(rawData, envelope);
console.log('Subject:', email.getHeader('subject'));
console.log('Body:', email.getBody());
})();
email.addHeader('X-Custom-Header', 'Hello World');
email.removeHeader('Received');
console.log(email.getHeader('from'));
console.log(email.envelope.senderIP); // 192.168.1.1
console.log(email.envelope.to); // ['[email protected]']
email.toString();