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

@ahmedayob/email-toolkit

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ahmedayob/email-toolkit

The Base64 utility class is a lightweight JavaScript library designed for encoding and decoding Base64 strings on the client side. It provides simple and efficient methods to convert text to Base64, decode Base64 back to text, and handle Base64 encoded da

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-88.24%
Maintainers
0
Weekly downloads
 
Created
Source

@ahmedayob/mime-builder

@ahmedayob/mime-builder is a TypeScript library for building and manipulating MIME (Multipurpose Internet Mail Extensions) messages. This library provides an easy-to-use API for creating, modifying, and encoding MIME messages, making it ideal for email and other internet-based communication systems.

Features

  • Create and Manipulate MIME Messages: Easily create and edit MIME messages.
  • Base64 Encoding/Decoding: Encode and decode MIME parts using Base64 encoding.
  • Header Management: Set and retrieve various headers including "Reply-To" and "Bcc".
  • MIME Boundaries: Generate unique MIME boundaries for different parts of a message.
  • Utility Functions: Convenient functions for encoding and decoding Base64 strings and URI encoding.

Installation

You can install @ahmedayob/mime-builder using npm or yarn:

npm install @ahmedayob/mime-builder

or

yarn add @ahmedayob/mime-builder

Usage

Here’s a basic example of how to use the @ahmedayob/mime-builder library:

import { MimeBuilder, Base64 } from "@ahmedayob/mime-builder";

// Create a new MIME message
const mimeMessage = new MimeBuilder();
mimeMessage.setHeader("From", "sender@example.com");
mimeMessage.setHeader("To", "recipient@example.com");
mimeMessage.setHeader("Subject", "Hello World");
mimeMessage.setHeader("Reply-To", "reply@example.com");

// Add a text part
mimeMessage.addPart({
  type: "text/plain",
  content: "This is a sample email message.",
});

// Generate MIME boundaries
mimeMessage.generateBoundaries();

// Retrieve headers
const headers = mimeMessage.getHeaders();
console.log(headers);

// Encode a string to Base64
const encodedString = Base64.encodeToBase64("Sample content");
console.log(encodedString);

// Decode a Base64 string
const decodedString = Base64.decodeToBinary(encodedString);
console.log(decodedString);

API

MimeBuilder

  • setHeader(name: string, value: unknown): string Sets a MIME header with the given name and value.

  • getHeader(name: string): string Retrieves the value of a specified MIME header.

  • setHeaders(obj: Record<string, unknown>): string[] Sets multiple headers from an object where keys are header names and values are their corresponding values.

  • getHeaders(): Record<string, unknown> Retrieves all headers as an object.

  • generateBoundaries(): void Generates unique MIME boundaries for different parts of the message.

  • isArray(v: unknown): v is Array<unknown> Checks if a value is an array.

  • isObject(v: unknown): v is Object Checks if a value is an object.

Base64

  • encodeToBase64(input: string): string Encodes a string into Base64.

  • decodeToBinary(input: string): string Decodes a Base64 encoded string into its original binary form.

  • deccodeToBuffer(input: string): Buffer Decodes a Base64 encoded string into a Buffer object.

  • toBufferURI(input: string): string Encodes a string to Base64 and then URI encodes the result.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

For questions or feedback, please reach out to ahmedayobbusiness@gmail.com.

This README provides a clear overview of the package, including its features, installation instructions, basic usage, API details, and contact information. Make sure to adjust any details if necessary, and add any additional sections or links that may be relevant.

Keywords

FAQs

Package last updated on 30 Jul 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