Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/mailparser

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/mailparser

TypeScript definitions for mailparser

  • 3.4.5
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
287K
increased by58.02%
Maintainers
1
Weekly downloads
 
Created

What is @types/mailparser?

@types/mailparser provides TypeScript definitions for the mailparser library, which is used to parse email messages. This package allows developers to work with email data in a structured way, making it easier to extract information such as headers, attachments, and body content.

What are @types/mailparser's main functionalities?

Parsing Email

This feature allows you to parse an email message and extract its headers, text content, and attachments. The code sample demonstrates how to set up event listeners for headers and data, and how to handle different types of data (text and attachments).

const MailParser = require('mailparser').MailParser;
const mailparser = new MailParser();

mailparser.on('headers', headers => {
  console.log(headers);
});

mailparser.on('data', data => {
  if (data.type === 'text') {
    console.log(data.text);
  } else if (data.type === 'attachment') {
    data.content.pipe(process.stdout);
  }
});

mailparser.write(emailSource);
mailparser.end();

Extracting Attachments

This feature allows you to extract attachments from an email message. The code sample demonstrates how to handle attachment data and save it to a file using a writable stream.

const MailParser = require('mailparser').MailParser;
const mailparser = new MailParser();

mailparser.on('data', data => {
  if (data.type === 'attachment') {
    data.content.pipe(fs.createWriteStream(data.filename));
  }
});

mailparser.write(emailSource);
mailparser.end();

Handling Multipart Emails

This feature allows you to handle multipart emails, which can contain both plain text and HTML content. The code sample demonstrates how to handle different types of content within a multipart email.

const MailParser = require('mailparser').MailParser;
const mailparser = new MailParser();

mailparser.on('data', data => {
  if (data.type === 'text') {
    console.log('Text:', data.text);
  } else if (data.type === 'html') {
    console.log('HTML:', data.html);
  }
});

mailparser.write(emailSource);
mailparser.end();

Other packages similar to @types/mailparser

FAQs

Package last updated on 07 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc