
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@ahmedayob/email-toolkit
Advanced tools
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.
@ahmedayob/email-toolkit
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.
EmailError
class.To install the toolkit, use npm or yarn:
npm install @ahmedayob/email-toolkit
# or
yarn add @ahmedayob/email-toolkit
Here's a quick guide on how to use the library:
Create and configure email headers:
import { EmailBuilderHeader } from "@ahmedayob/email-toolkit";
const header = new EmailBuilderHeader();
header
.setFrom("ahmed <ahmed@gmail.com>")
.setTo("ahmed <ahmed@gmail.com>")
.setCc("ahmed <ahmed@gmail.com>")
.setBcc("ahmed <ahmed@gmail.com>")
.setSubject("This is a test email subject")
.setInReplyTo("ahmed@gmail.com")
.setMIMEVersion("1.0")
.setContentTransferEncoding("quoted-printable")
.setContentType("text/html")
.setCharset("utf-8");
Add attachments to your email:
import { EmailBuilderAttachment, Base64 } from "@ahmedayob/email-toolkit";
const attachment = new EmailBuilderAttachment();
attachment.addAttachment({
headers: {
"Content-Type": 'text/plain; charset="utf-8"',
"Content-Transfer-Encoding": "base64",
"Content-Disposition": 'attachment; filename="test.txt"',
},
size: 1234,
filename: "test.txt",
mimeType: "text/plain",
attachmentId: "1234",
attachmentContent: Base64.encodeToBase64(
"This is the content of the attachment."
),
});
Combine headers and attachments to create the final email:
import { EmailBuilder } from "@ahmedayob/email-toolkit";
const email = new EmailBuilder();
email.messagebody = "<p>This is the message body</p>";
const finalEmail = email.getRawMessage(header.headers, attachment.attachments);
console.log(finalEmail);
Generate base64-encoded messages and email signatures:
import { EmailBuilder } from "@ahmedayob/email-toolkit";
const email = new EmailBuilder();
email.messagebody = "<p>This is the message body</p>";
const encodedMessage = email.getEncodedMessage(
header.headers,
attachment.attachments
);
console.log(encodedMessage);
email.setSignature({
url: "https://github.com/wildduck2",
name: "Ahmed Ayob",
});
const signature = email.getSignature({
from: "ahmed@example.com",
url: "https://github.com/wildduck2",
name: "Ahmed Ayob",
});
console.log(signature.join("\n"));
EmailBuilderHeader
EmailBuilderAttachment
EmailBuilder
Base64
EmailError
EmailError
.Validation schemas are available to ensure data correctness:
Contributions are welcome! Please open issues and pull requests on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for details.
0.2.2
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.
The npm package @ahmedayob/email-toolkit receives a total of 11 weekly downloads. As such, @ahmedayob/email-toolkit popularity was classified as not popular.
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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.