Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@ahmedayob/email-toolkit
Advanced tools
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
@ahmedayob/email-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.
You can install @ahmedayob/email-builder
using npm or yarn:
npm install @ahmedayob/email-builder
or
yarn add @ahmedayob/email-builder
Here’s a basic example of how to use the @ahmedayob/email-builder
library:
import { MimeBuilder, Base64 } from "@ahmedayob/email-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);
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.
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.
This project is licensed under the MIT License. See the LICENSE file for more details.
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.
FAQs
A powerful and flexible toolkit for building, validating, and processing emails with TypeScript. This library offers utilities for handling email headers, attachments, and encoding, making it easier to compose and manage emails programmatically.
We found that @ahmedayob/email-toolkit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.