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 - npm Package Compare versions

Comparing version 0.1.11 to 0.2.0

495

dist/index.d.ts

@@ -223,58 +223,142 @@ import z, { z as z$1 } from 'zod';

* Provides methods to validate headers, data, charset, MIME type, content type, and content transfer encoding.
*
* @class
* @implements {EmailValidatorClass}
*/
declare class EmailValidator implements EmailValidatorClass {
/**
* Validates email headers using the HeadersTypeSchema.
* Validates email headers using the `HeadersTypeSchema`.
*
* @param headers - The headers to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {HeadersType | undefined} headers - The headers to be validated. Must conform to the `HeadersType` schema. If `undefined`, the validation result will be based on the provided headers or lack thereof.
* @returns {z.SafeParseReturnType<HeadersType, z.infer<typeof HeadersTypeSchema>>} A Zod safe parse result containing the validation outcome, including data if valid or errors if invalid.
*
* @example
* const headers = {
* "From": "example <example@example.com>",
* "To": "recipient <recipient@example.com>",
* "Subject": "Hello World"
* };
* const result = emailValidator.isValidHeaders(headers);
* if (result.success) {
* console.log("Headers are valid:", result.data);
* } else {
* console.error("Header validation errors:", result.error);
* }
*/
isValidHeaders(headers: HeadersType | undefined): z$1.SafeParseReturnType<HeadersType, z$1.infer<typeof HeadersTypeSchema>>;
/**
* Validates a string data using the StringSchema.
* Validates a string data using the `StringSchema`.
*
* @param data - The data to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {string} data - The data to be validated. Must be a string conforming to the `StringSchema`.
* @returns {z.SafeParseReturnType<string, string>} A Zod safe parse result containing the validation outcome, which includes the data if valid or errors if invalid.
*
* @example
* const data = "This is a sample string.";
* const result = emailValidator.isValidData(data);
* if (result.success) {
* console.log("Data is valid:", result.data);
* } else {
* console.error("Data validation errors:", result.error);
* }
*/
isValidData(data: string): z$1.SafeParseReturnType<string, string>;
/**
* Validates a character set using the StringSchema.
* Validates a character set using the `StringSchema`.
*
* @param charset - The charset to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {string} charset - The charset to be validated. Must be a string conforming to the `StringSchema`.
* @returns {z.SafeParseReturnType<string, string>} A Zod safe parse result containing the validation outcome, which includes the charset if valid or errors if invalid.
*
* @example
* const charset = "UTF-8";
* const result = emailValidator.isValidCharset(charset);
* if (result.success) {
* console.log("Charset is valid:", result.data);
* } else {
* console.error("Charset validation errors:", result.error);
* }
*/
isValidCharset(charset: string): z$1.SafeParseReturnType<string, string>;
/**
* Validates a MIME type using the StringSchema.
* Validates a MIME type using the `StringSchema`.
*
* @param mimeType - The MIME type to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {string} mimeType - The MIME type to be validated. Must be a string conforming to the `StringSchema`.
* @returns {z.SafeParseReturnType<string, string>} A Zod safe parse result containing the validation outcome, which includes the MIME type if valid or errors if invalid.
*
* @example
* const mimeType = "text/plain";
* const result = emailValidator.isValidMimeType(mimeType);
* if (result.success) {
* console.log("MIME type is valid:", result.data);
* } else {
* console.error("MIME type validation errors:", result.error);
* }
*/
isValidMimeType(mimeType: string): z$1.SafeParseReturnType<string, string>;
/**
* Validates a content type using the StringSchema.
* Validates a content type using the `StringSchema`.
*
* @param contentType - The content type to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {string} contentType - The content type to be validated. Must be a string conforming to the `StringSchema`.
* @returns {z.SafeParseReturnType<string, string>} A Zod safe parse result containing the validation outcome, which includes the content type if valid or errors if invalid.
*
* @example
* const contentType = "text/html";
* const result = emailValidator.isValidContentType(contentType);
* if (result.success) {
* console.log("Content type is valid:", result.data);
* } else {
* console.error("Content type validation errors:", result.error);
* }
*/
isValidContentType(contentType: string): z$1.SafeParseReturnType<string, string>;
/**
* Validates content transfer encoding using the ContentTransferEncodingSchema.
* Validates content transfer encoding using the `ContentTransferEncodingSchema`.
*
* @param encoding - The encoding to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {ContentTransferEncoding} encoding - The encoding to be validated. Must conform to the `ContentTransferEncodingSchema`.
* @returns {z.SafeParseReturnType<ContentTransferEncoding, ContentTransferEncoding>} A Zod safe parse result containing the validation outcome, which includes the encoding if valid or errors if invalid.
*
* @example
* const encoding = "base64";
* const result = emailValidator.isValidContentTransferEncoding(encoding);
* if (result.success) {
* console.log("Content transfer encoding is valid:", result.data);
* } else {
* console.error("Content transfer encoding validation errors:", result.error);
* }
*/
isValidContentTransferEncoding(encoding: ContentTransferEncoding$1): z$1.SafeParseReturnType<ContentTransferEncoding$1, ContentTransferEncoding$1>;
/**
* Logs an error by throwing an EmailError with the provided Zod error details.
* Logs an error by throwing an `EmailError` with the provided Zod error details.
*
* @param error - The Zod error to be logged.
* @throws {EmailError} Throws an EmailError with the error message.
* @param {z.ZodError} error - The Zod error to be logged. Contains detailed error information from the Zod validation process.
* @throws {EmailError} Throws an `EmailError` with the error message and description based on the Zod error.
*
* @example
* try {
* const result = emailValidator.isValidData("Invalid data");
* if (!result.success) {
* emailValidator.logError(result.error);
* }
* } catch (e) {
* console.error("An error occurred:", e);
* }
*/
logError(error: z$1.ZodError): void;
/**
* Validates an attachment header using the AttachmentHeaderSchema.
* Validates an attachment header using the `AttachmentHeaderSchema`.
*
* @param attachmentHeader - The attachment header to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {z.infer<typeof AttachmentHeaderSchema>} attachmentHeader - The attachment header to be validated. Must conform to the `AttachmentHeaderSchema`.
* @returns {z.SafeParseReturnType<z.infer<typeof AttachmentHeaderSchema>, z.infer<typeof AttachmentHeaderSchema>>} A Zod safe parse result containing the validation outcome, which includes the attachment header if valid or errors if invalid.
*
* @example
* const attachmentHeader = {
* "Content-Type": "application/pdf",
* "Content-Disposition": "attachment; filename=\"example.pdf\"",
* "Content-Transfer-Encoding": "base64"
* };
* const result = emailValidator.isValidAttachment(attachmentHeader);
* if (result.success) {
* console.log("Attachment header is valid:", result.data);
* } else {
* console.error("Attachment header validation errors:", result.error);
* }
*/

@@ -300,4 +384,4 @@ isValidAttachment(attachmentHeader: z$1.infer<typeof AttachmentHeaderSchema>): z$1.SafeParseReturnType<z$1.infer<typeof AttachmentHeaderSchema>, z$1.infer<typeof AttachmentHeaderSchema>>;

}
type EmailTypeString = `${string}@${string}.${string}`;
type ValueType = `${string} <${EmailTypeString}>`;
type EmailTypeString = `<${string}@${string}.${string}>`;
type ValueType = `${string} ${EmailTypeString}`;
type TupleUnion<T extends readonly unknown[]> = T[number];

@@ -322,3 +406,18 @@ type HeaderskeyNameType = z$1.infer<typeof HeadersTypeSchema>;

* Class for building and validating email headers.
* Extends the `EmailValidator` class and implements `EmailBuilderHeaderClass`.
*
* This class extends the `EmailValidator` class and implements the `EmailBuilderHeaderClass` interface.
* It provides methods to set various email headers and validate them according to email standards.
*
* The class allows you to configure email headers such as "From", "To", "Cc", "Bcc", "Subject", and more.
* It ensures that headers are set correctly and adheres to the email format standards.
*
* @extends {EmailValidator}
* @implements {EmailBuilderHeaderClass}
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader
* .setFrom("sender@example.com")
* .setTo("recipient@example.com")
* .setSubject("Test Email");
*/

@@ -329,2 +428,6 @@ declare class EmailBuilderHeader extends EmailValidator implements EmailBuilderHeaderClass {

*
* This property holds all the headers associated with the email. It includes fields such as "From", "To", "Subject",
* "Cc", "Bcc", "Date", and other standard email headers. The `HeadersType` defines the structure and types
* for each header field.
*
* @type {HeadersType}

@@ -338,82 +441,186 @@ */

/**
* Retrieves the validated email headers.
* Retrieves the email headers after validating them.
*
* @returns {HeadersType} The validated email headers.
* This method validates the current headers stored in the instance using the `isValidHeaders` method.
* If any validation errors are detected, they are logged, but the method still returns the parsed headers.
*
* @returns {HeadersType} The validated and parsed email headers.
*
* @example
* const emailBuilder = new EmailBuilder();
* emailBuilder.setHeaders({
* From: "sender@example.com",
* To: "recipient@example.com",
* Subject: "Test Email"
* });
* const headers = emailBuilder.getHeaders();
* console.log(headers);
*/
getHeaders(): HeadersType;
/**
* Sets the "From" header.
* Sets the headers for the email.
*
* @param {ValueType} From - The sender's email address.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method validates the provided headers using the `isValidHeaders` method.
* If the headers are invalid, it logs the error and still assigns the headers.
*
* @param {HeadersType} headers - The headers object to be set. This should contain key-value pairs representing the email headers.
* @returns {this} The current instance of the EmailBuilder class for method chaining.
*
* @example
* const emailBuilder = new EmailBuilder();
* emailBuilder.setHeaders({
* "From": "sender@example.com",
* "To": "recipient@example.com",
* "Subject": "Test Email"
* });
*/
setHeaders(headers: HeadersType): this;
/**
* Sets the "From" header of the email.
*
* This method allows you to specify the sender's email address by setting the "From" header.
*
* @param {ValueType} From - The sender's email address, typically in the format `"name@example.com"` or `"Name <name@example.com>"`.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setFrom("sender@example.com");
*/
setFrom(From: ValueType): this;
/**
* Sets the "To" header.
* Sets the "To" header of the email.
*
* @param {ValueType} To - The recipient's email address.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the recipient's email address. The "To" header indicates the primary recipient(s) of the email. It can include individual email addresses or multiple addresses separated by commas.
*
* @param {ValueType} To - The recipient's email address or addresses. This should be a string in the format `"name@example.com"` or `"Name <name@example.com>"`, or a comma-separated list of such addresses.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setTo("recipient@example.com");
*
* // For multiple recipients
* emailHeader.setTo("recipient1@example.com, recipient2@example.com");
*/
setTo(To: ValueType): this;
/**
* Sets the "Cc" header.
* Sets the "Cc" (Carbon Copy) header of the email.
*
* @param {ValueType} Cc - The carbon copy recipient's email address.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method allows you to specify additional recipients who will receive a copy of the email. The email address can be in a simple format or include a name.
*
* @param {ValueType} Cc - The carbon copy recipient's email address. This can be a single email address or multiple addresses separated by commas.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setCc("cc@example.com");
* // or with multiple addresses
* emailHeader.setCc("cc1@example.com, cc2@example.com");
*/
setCc(Cc: ValueType): this;
/**
* Sets the "Bcc" header.
* Sets the "Bcc" (Blind Carbon Copy) header of the email.
*
* @param {ValueType} Bcc - The blind carbon copy recipient's email address.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method allows you to specify additional recipients who will receive a blind copy of the email. Their addresses will be hidden from other recipients.
*
* @param {ValueType} Bcc - The blind carbon copy recipient's email address. This can be a single email address or multiple addresses separated by commas.
* @returns {this} The current instance of `EmailBuilderHeader`, enabling method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setBcc("bcc@example.com");
* // or with multiple addresses
* emailHeader.setBcc("bcc1@example.com, bcc2@example.com");
*/
setBcc(Bcc: ValueType): this;
/**
* Sets the "Date" header.
* Sets the "Date" header of the email.
*
* @param {string} Date - The date of the email.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method allows you to specify the date and time when the email is being sent. The date should be in a standard format that is compliant with RFC 5322.
*
* @param {string} Date - The date and time of the email in a string format. Example: `"Tue, 15 Aug 2024 10:00:00 +0000"`.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setDate("Tue, 15 Aug 2024 10:00:00 +0000");
*/
setDate(Date: string): this;
/**
* Sets the "Subject" header.
* Sets the "Subject" header of the email.
*
* @param {string} Subject - The subject of the email.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method allows you to specify the subject line of the email. The subject should be a concise summary of the email's content.
*
* @param {string} Subject - The subject of the email. Example: `"Meeting Reminder: Project Update"`.
* @returns {this} The current instance of `EmailBuilderHeader`, enabling method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setSubject("Meeting Reminder: Project Update");
*/
setSubject(Subject: string): this;
/**
* Sets the "In-Reply-To" header.
* Sets the "In-Reply-To" header of the email.
*
* @param {EmailTypeString} InReplyTo - The email ID that this email is in reply to.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the email ID that this email is replying to. The "In-Reply-To" header is used to indicate the message ID of the original message in a reply or thread.
*
* @param {EmailTypeString} InReplyTo - The email ID or message ID that this email is in reply to. This should be a string representing the unique identifier of the original email.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setInReplyTo("<message-id@example.com>");
*/
setInReplyTo(InReplyTo: EmailTypeString): this;
/**
* Sets the "MIME-Version" header.
* Sets the "MIME-Version" header of the email.
*
* @param {string} MIMEVersion - The MIME version of the email.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the MIME version used in the email. The "MIME-Version" header indicates the version of the MIME protocol that is being used for the email content.
*
* @param {string} MIMEVersion - The MIME version of the email, typically `"1.0"`. This indicates the version of the MIME protocol used.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setMIMEVersion("1.0");
*/
setMIMEVersion(MIMEVersion: string): this;
/**
* Sets the "Content-Transfer-Encoding" header.
* Sets the "Content-Transfer-Encoding" header of the email.
*
* @param {ContentTransferEncoding} ContentTransferEncoding - The encoding for the email content.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the encoding used for the email content. The "Content-Transfer-Encoding" header describes how the email content is encoded for transmission.
*
* @param {ContentTransferEncoding} ContentTransferEncoding - The encoding for the email content, such as `"7bit"`, `"8bit"`, `"base64"`, or `"quoted-printable"`.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setContentTransferEncoding("base64");
*/
setContentTransferEncoding(ContentTransferEncoding: ContentTransferEncoding$1): this;
/**
* Sets the "Content-Type" header.
* Sets the "Content-Type" header of the email.
*
* @param {TupleUnion<MIMEType>} ContentType - The MIME type of the email content.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the MIME type of the email content. The "Content-Type" header indicates the media type and sub-type of the content, such as `"text/plain"` or `"text/html"`.
*
* @param {TupleUnion<MIMEType>} ContentType - The MIME type of the email content. This should be a string representing the type and sub-type of the content (e.g., `"text/html"` or `"multipart/alternative"`).
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setContentType("text/html");
*/
setContentType(ContentType: TupleUnion<MIMEType>): this;
/**
* Sets the "Charset" header.
* Sets the "Charset" header of the email.
*
* @param {TupleUnion<typeof CharsetType>} Charset - The character set used in the email.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the character set used in the email. The "Charset" header indicates the encoding standard for the email content, such as `"utf-8"` or `"iso-8859-1"`.
*
* @param {TupleUnion<typeof CharsetType>} Charset - The character set used in the email. This should be a string representing the character encoding standard (e.g., `"utf-8"` or `"iso-8859-1"`).
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setCharset("utf-8");
*/

@@ -434,5 +641,9 @@ setCharset(Charset: TupleUnion<typeof CharsetType>): this;

type MIMEType = typeof MIMETypes;
interface EmailBuilderClass {
declare class EmailBuilderClass {
constructor();
getSignature({ from, url, name }: GetSignatureType): string[];
setSignature({ name, url, }: NonNullableType<Omit<GetSignatureType, "from">>): this;
}
interface ApplicationSignature {
from: string;
name: string;

@@ -492,2 +703,5 @@ url: string;

};
type NonNullableType<T> = {
[K in keyof T]: NonNullable<T[K]>;
};

@@ -499,5 +713,32 @@ interface EmailErrorInterface {

/**
* Custom error class for handling email-related errors.
* This class extends the built-in `Error` class and implements the `EmailErrorInterface`.
* It provides additional details about the error through a `description` property.
*
* @class
* @implements {EmailErrorInterface}
*/
declare class EmailError extends Error implements EmailErrorInterface {
/**
* The name of the error. It is set to the provided message.
*
* @type {string}
*/
name: string;
/**
* A description of the error providing additional context.
* Initialized as an empty string and set via the constructor.
*
* @type {string}
*/
description: string;
/**
* Creates an instance of `EmailError`.
* Initializes the error with a message and a description.
*
* @param {Object} params - The parameters to initialize the error.
* @param {string} params.message - The message describing the error.
* @param {string} params.description - A detailed description of the error.
*/
constructor({ message, description, }: {

@@ -510,4 +751,7 @@ message: string;

/**
* Class representing an EmailBuilder.
* Class representing an `EmailBuilder`.
*
* This class is used for constructing and validating email headers, as well as generating email messages with optional attachments and signatures.
* It implements the `EmailBuilderClass` interface, providing methods for setting various email headers and constructing raw or encoded email messages.
*
* @implements {EmailBuilderClass}

@@ -518,2 +762,5 @@ */

* The body of the email message.
*
* This property holds the content of the email message. It can be a string containing the message body or `null` if no body is set.
*
* @type {string | null}

@@ -524,7 +771,12 @@ */

* Application signature details.
*
* This property contains the details for the email signature, including the URL and name associated with the application or service.
*
* @type {ApplicationSignature}
*/
applicationSignature: ApplicationSignature;
applicationSignature: Omit<ApplicationSignature, "from">;
/**
* Creates an instance of EmailBuilder.
* Creates an instance of the `EmailBuilder` class.
*
* The constructor initializes an instance of `EmailBuilder`, setting up default values for `messagebody` and `applicationSignature`.
*/

@@ -535,5 +787,36 @@ constructor();

*
* @param {HeadersType} headers - The headers for the email.
* @param {AttachmentType[]} [attachments] - Optional attachments to include in the email.
* @returns {string | EmailError} The raw email message or an EmailError if the message body is missing.
* This method constructs the raw email message by combining the provided headers, message body, and any optional
* attachments. It formats the email content as HTML and includes boundary markers for multipart content.
* If the email message body is missing, it returns an `EmailError`.
*
* @param {HeadersType} headers - The headers for the email. This includes fields such as "To", "From", "Subject", etc.
* @param {AttachmentType[]} [attachments] - Optional attachments to include in the email. Each attachment includes
* headers, content type, and content.
* @returns {string | EmailError} The raw email message formatted as a string. If the message body is missing,
* returns an `EmailError` indicating that the message body is required.
*
* @example
* const emailBuilder = new EmailBuilder();
* emailBuilder.messagebody = "This is the body of the email.";
* const rawMessage = emailBuilder.getRawMessage(
* {
* To: "recipient <recipient@example.com>",
* From: "sender <sender@example.com>",
* Subject: "Test Email",
* "Content-Type": "text/html",
* "Content-Transfer-Encoding": "quoted-printable"
* },
* [
* {
* headers: {
* "Content-Type": "text/plain; charset=\"utf-8\"",
* "Content-Transfer-Encoding": "base64",
* "Content-Disposition": "attachment; filename=\"test.txt\""
* },
* filename: "test.txt",
* attachmentContent: "dGVzdCBjb250ZW50"
* }
* ]
* );
* console.log(rawMessage);
*/

@@ -545,8 +828,33 @@ getRawMessage(headers: HeadersType, attachments?: AttachmentType[]): string | EmailError;

* This method first constructs the raw email message using the provided headers and optional attachments.
* If the raw message construction results in an `EmailError`, the method returns the error message.
* Otherwise, it encodes the raw message in base64 format and returns it.
* If the raw message construction results in an `EmailError`, it returns the error message. Otherwise,
* it encodes the raw message in base64 format and returns the encoded string.
*
* @param headers - An object representing the email headers. Must conform to the `HeadersType` schema.
* @param attachments - (Optional) An array of attachments to be included in the email. Each attachment must conform to the `AttachmentType` schema.
* @returns The base64-encoded email message as a string, or an error message if an `EmailError` occurred.
* @param {HeadersType} headers - An object representing the email headers. This should include fields such as "To", "From", "Subject", etc.
* @param {AttachmentType[]} [attachments] - Optional. An array of attachments to be included in the email. Each attachment should conform to the `AttachmentType` schema.
* @returns {string} The base64-encoded email message as a string. If an `EmailError` occurred during raw message construction, the method returns the error message.
*
* @example
* const emailBuilder = new EmailBuilder();
* emailBuilder.messagebody = "This is the body of the email.";
* const encodedMessage = emailBuilder.getEncodedMessage(
* {
* To: "recipient <recipient@example.com>",
* From: "sender <sender@example.com>",
* Subject: "Test Email",
* "Content-Type": "text/html",
* "Content-Transfer-Encoding": "quoted-printable"
* },
* [
* {
* headers: {
* "Content-Type": "text/plain; charset=\"utf-8\"",
* "Content-Transfer-Encoding": "base64",
* "Content-Disposition": "attachment; filename=\"test.txt\""
* },
* filename: "test.txt",
* attachmentContent: "dGVzdCBjb250ZW50"
* }
* ]
* );
* console.log(encodedMessage);
*/

@@ -557,8 +865,41 @@ getEncodedMessage(headers: HeadersType, attachments?: AttachmentType[]): string;

*
* @param {GetSignatureType} signatureDetails - An object containing the sender's email, application URL, and name.
* @returns {string[]} The formatted signature block as an array of strings.
* This method creates a formatted signature block to be included in the email. The signature contains
* information about the sender and the application used to send the email. It returns the signature block
* as an array of strings, which can be included in the email body.
*
* @param {GetSignatureType} signatureDetails - An object containing the details for the signature. It should include:
* - `from`: The sender's email address.
* - `url`: The URL of the application used to send the email.
* - `name`: The name of the application.
* @returns {string[]} An array of strings representing the formatted signature block.
*
* @example
* const signature = emailBuilder.getSignature({
* from: "sender@example.com",
* url: "https://example.com",
* name: "ExampleApp"
* });
* console.log(signature.join("\n"));
*/
getSignature({ from, url, name }: GetSignatureType): string[];
/**
* Sets the signature details for the email.
*
* This method updates the `applicationSignature` property with the provided URL and name.
* The `url` and `name` parameters must be non-nullable and are used to personalize the email signature.
*
* @param {Object} params - The signature details.
* @param {string} params.url - The URL associated with the email signature, such as the website or application URL.
* @param {string} params.name - The name associated with the email signature, such as the name of the application or service.
* @returns {this}
*
* @example
* emailBuilder.setSignature({
* url: "https://example.com",
* name: "ExampleApp"
* });
*/
setSignature({ url, name, }: NonNullableType<Omit<GetSignatureType, "from">>): this;
}
export { type AddMessageType, type ApplicationSignature, type AttachmentContentType, AttachmentHeaderSchema, type AttachmentType, type AttachmentTypeType, Base64, CharsetType, CharsetTypeSchema, type ContentDispositionType, ContentTransferEncoding, ContentTransferEncodingSchema, ContentTypeSchema, EmailBuilder, type EmailBuilderClass, EmailBuilderHeader, EmailBuilderHeaderClass, EmailError, type EmailErrorInterface, type EmailType, type EmailTypeString, EmailValidator, EmailValidatorClass, type ExcludedHeadernameType, type GetSignatureType, type HeadernameType, type HeadersType, HeadersTypeSchema, type HeaderskeyNameType, type MIMEType, MIMETypes, type RawMessage, type SetHeaderType, StringSchema, type TupleUnion, type ValueType };
export { type AddMessageType, type ApplicationSignature, type AttachmentContentType, AttachmentHeaderSchema, type AttachmentType, type AttachmentTypeType, Base64, CharsetType, CharsetTypeSchema, type ContentDispositionType, ContentTransferEncoding, ContentTransferEncodingSchema, ContentTypeSchema, EmailBuilder, EmailBuilderClass, EmailBuilderHeader, EmailBuilderHeaderClass, EmailError, type EmailErrorInterface, type EmailType, type EmailTypeString, EmailValidator, EmailValidatorClass, type ExcludedHeadernameType, type GetSignatureType, type HeadernameType, type HeadersType, HeadersTypeSchema, type HeaderskeyNameType, type MIMEType, MIMETypes, type NonNullableType, type RawMessage, type SetHeaderType, StringSchema, type TupleUnion, type ValueType };

@@ -135,4 +135,23 @@ "use strict";

var EmailError = class extends Error {
/**
* The name of the error. It is set to the provided message.
*
* @type {string}
*/
name;
/**
* A description of the error providing additional context.
* Initialized as an empty string and set via the constructor.
*
* @type {string}
*/
description = "";
/**
* Creates an instance of `EmailError`.
* Initializes the error with a message and a description.
*
* @param {Object} params - The parameters to initialize the error.
* @param {string} params.message - The message describing the error.
* @param {string} params.description - A detailed description of the error.
*/
constructor({

@@ -153,2 +172,5 @@ message,

* The body of the email message.
*
* This property holds the content of the email message. It can be a string containing the message body or `null` if no body is set.
*
* @type {string | null}

@@ -159,2 +181,5 @@ */

* Application signature details.
*
* This property contains the details for the email signature, including the URL and name associated with the application or service.
*
* @type {ApplicationSignature}

@@ -167,3 +192,5 @@ */

/**
* Creates an instance of EmailBuilder.
* Creates an instance of the `EmailBuilder` class.
*
* The constructor initializes an instance of `EmailBuilder`, setting up default values for `messagebody` and `applicationSignature`.
*/

@@ -175,5 +202,36 @@ constructor() {

*
* @param {HeadersType} headers - The headers for the email.
* @param {AttachmentType[]} [attachments] - Optional attachments to include in the email.
* @returns {string | EmailError} The raw email message or an EmailError if the message body is missing.
* This method constructs the raw email message by combining the provided headers, message body, and any optional
* attachments. It formats the email content as HTML and includes boundary markers for multipart content.
* If the email message body is missing, it returns an `EmailError`.
*
* @param {HeadersType} headers - The headers for the email. This includes fields such as "To", "From", "Subject", etc.
* @param {AttachmentType[]} [attachments] - Optional attachments to include in the email. Each attachment includes
* headers, content type, and content.
* @returns {string | EmailError} The raw email message formatted as a string. If the message body is missing,
* returns an `EmailError` indicating that the message body is required.
*
* @example
* const emailBuilder = new EmailBuilder();
* emailBuilder.messagebody = "This is the body of the email.";
* const rawMessage = emailBuilder.getRawMessage(
* {
* To: "recipient <recipient@example.com>",
* From: "sender <sender@example.com>",
* Subject: "Test Email",
* "Content-Type": "text/html",
* "Content-Transfer-Encoding": "quoted-printable"
* },
* [
* {
* headers: {
* "Content-Type": "text/plain; charset=\"utf-8\"",
* "Content-Transfer-Encoding": "base64",
* "Content-Disposition": "attachment; filename=\"test.txt\""
* },
* filename: "test.txt",
* attachmentContent: "dGVzdCBjb250ZW50"
* }
* ]
* );
* console.log(rawMessage);
*/

@@ -201,3 +259,7 @@ getRawMessage(headers, attachments) {

``,
this.getSignature({ from: headers.From, ...this.applicationSignature })
this.getSignature({
...this.applicationSignature,
from: headers.From
}),
`</div>`
].join("\r\n");

@@ -236,8 +298,33 @@ const Attachments = attachments?.flatMap((attachment) => {

* This method first constructs the raw email message using the provided headers and optional attachments.
* If the raw message construction results in an `EmailError`, the method returns the error message.
* Otherwise, it encodes the raw message in base64 format and returns it.
* If the raw message construction results in an `EmailError`, it returns the error message. Otherwise,
* it encodes the raw message in base64 format and returns the encoded string.
*
* @param headers - An object representing the email headers. Must conform to the `HeadersType` schema.
* @param attachments - (Optional) An array of attachments to be included in the email. Each attachment must conform to the `AttachmentType` schema.
* @returns The base64-encoded email message as a string, or an error message if an `EmailError` occurred.
* @param {HeadersType} headers - An object representing the email headers. This should include fields such as "To", "From", "Subject", etc.
* @param {AttachmentType[]} [attachments] - Optional. An array of attachments to be included in the email. Each attachment should conform to the `AttachmentType` schema.
* @returns {string} The base64-encoded email message as a string. If an `EmailError` occurred during raw message construction, the method returns the error message.
*
* @example
* const emailBuilder = new EmailBuilder();
* emailBuilder.messagebody = "This is the body of the email.";
* const encodedMessage = emailBuilder.getEncodedMessage(
* {
* To: "recipient <recipient@example.com>",
* From: "sender <sender@example.com>",
* Subject: "Test Email",
* "Content-Type": "text/html",
* "Content-Transfer-Encoding": "quoted-printable"
* },
* [
* {
* headers: {
* "Content-Type": "text/plain; charset=\"utf-8\"",
* "Content-Transfer-Encoding": "base64",
* "Content-Disposition": "attachment; filename=\"test.txt\""
* },
* filename: "test.txt",
* attachmentContent: "dGVzdCBjb250ZW50"
* }
* ]
* );
* console.log(encodedMessage);
*/

@@ -254,4 +341,19 @@ getEncodedMessage(headers, attachments) {

*
* @param {GetSignatureType} signatureDetails - An object containing the sender's email, application URL, and name.
* @returns {string[]} The formatted signature block as an array of strings.
* This method creates a formatted signature block to be included in the email. The signature contains
* information about the sender and the application used to send the email. It returns the signature block
* as an array of strings, which can be included in the email body.
*
* @param {GetSignatureType} signatureDetails - An object containing the details for the signature. It should include:
* - `from`: The sender's email address.
* - `url`: The URL of the application used to send the email.
* - `name`: The name of the application.
* @returns {string[]} An array of strings representing the formatted signature block.
*
* @example
* const signature = emailBuilder.getSignature({
* from: "sender@example.com",
* url: "https://example.com",
* name: "ExampleApp"
* });
* console.log(signature.join("\n"));
*/

@@ -269,2 +371,29 @@ getSignature({ from, url, name }) {

}
/**
* Sets the signature details for the email.
*
* This method updates the `applicationSignature` property with the provided URL and name.
* The `url` and `name` parameters must be non-nullable and are used to personalize the email signature.
*
* @param {Object} params - The signature details.
* @param {string} params.url - The URL associated with the email signature, such as the website or application URL.
* @param {string} params.name - The name associated with the email signature, such as the name of the application or service.
* @returns {this}
*
* @example
* emailBuilder.setSignature({
* url: "https://example.com",
* name: "ExampleApp"
* });
*/
setSignature({
url,
name
}) {
this.applicationSignature = {
url,
name
};
return this;
}
};

@@ -340,3 +469,3 @@

*/
"In-Reply-To": import_zod.default.string().email().optional(),
"In-Reply-To": import_zod.default.string().optional(),
/**

@@ -394,6 +523,19 @@ * The content type of the email.

/**
* Validates email headers using the HeadersTypeSchema.
* Validates email headers using the `HeadersTypeSchema`.
*
* @param headers - The headers to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {HeadersType | undefined} headers - The headers to be validated. Must conform to the `HeadersType` schema. If `undefined`, the validation result will be based on the provided headers or lack thereof.
* @returns {z.SafeParseReturnType<HeadersType, z.infer<typeof HeadersTypeSchema>>} A Zod safe parse result containing the validation outcome, including data if valid or errors if invalid.
*
* @example
* const headers = {
* "From": "example <example@example.com>",
* "To": "recipient <recipient@example.com>",
* "Subject": "Hello World"
* };
* const result = emailValidator.isValidHeaders(headers);
* if (result.success) {
* console.log("Headers are valid:", result.data);
* } else {
* console.error("Header validation errors:", result.error);
* }
*/

@@ -404,6 +546,15 @@ isValidHeaders(headers) {

/**
* Validates a string data using the StringSchema.
* Validates a string data using the `StringSchema`.
*
* @param data - The data to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {string} data - The data to be validated. Must be a string conforming to the `StringSchema`.
* @returns {z.SafeParseReturnType<string, string>} A Zod safe parse result containing the validation outcome, which includes the data if valid or errors if invalid.
*
* @example
* const data = "This is a sample string.";
* const result = emailValidator.isValidData(data);
* if (result.success) {
* console.log("Data is valid:", result.data);
* } else {
* console.error("Data validation errors:", result.error);
* }
*/

@@ -414,6 +565,15 @@ isValidData(data) {

/**
* Validates a character set using the StringSchema.
* Validates a character set using the `StringSchema`.
*
* @param charset - The charset to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {string} charset - The charset to be validated. Must be a string conforming to the `StringSchema`.
* @returns {z.SafeParseReturnType<string, string>} A Zod safe parse result containing the validation outcome, which includes the charset if valid or errors if invalid.
*
* @example
* const charset = "UTF-8";
* const result = emailValidator.isValidCharset(charset);
* if (result.success) {
* console.log("Charset is valid:", result.data);
* } else {
* console.error("Charset validation errors:", result.error);
* }
*/

@@ -424,6 +584,15 @@ isValidCharset(charset) {

/**
* Validates a MIME type using the StringSchema.
* Validates a MIME type using the `StringSchema`.
*
* @param mimeType - The MIME type to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {string} mimeType - The MIME type to be validated. Must be a string conforming to the `StringSchema`.
* @returns {z.SafeParseReturnType<string, string>} A Zod safe parse result containing the validation outcome, which includes the MIME type if valid or errors if invalid.
*
* @example
* const mimeType = "text/plain";
* const result = emailValidator.isValidMimeType(mimeType);
* if (result.success) {
* console.log("MIME type is valid:", result.data);
* } else {
* console.error("MIME type validation errors:", result.error);
* }
*/

@@ -434,6 +603,15 @@ isValidMimeType(mimeType) {

/**
* Validates a content type using the StringSchema.
* Validates a content type using the `StringSchema`.
*
* @param contentType - The content type to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {string} contentType - The content type to be validated. Must be a string conforming to the `StringSchema`.
* @returns {z.SafeParseReturnType<string, string>} A Zod safe parse result containing the validation outcome, which includes the content type if valid or errors if invalid.
*
* @example
* const contentType = "text/html";
* const result = emailValidator.isValidContentType(contentType);
* if (result.success) {
* console.log("Content type is valid:", result.data);
* } else {
* console.error("Content type validation errors:", result.error);
* }
*/

@@ -444,6 +622,15 @@ isValidContentType(contentType) {

/**
* Validates content transfer encoding using the ContentTransferEncodingSchema.
* Validates content transfer encoding using the `ContentTransferEncodingSchema`.
*
* @param encoding - The encoding to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {ContentTransferEncoding} encoding - The encoding to be validated. Must conform to the `ContentTransferEncodingSchema`.
* @returns {z.SafeParseReturnType<ContentTransferEncoding, ContentTransferEncoding>} A Zod safe parse result containing the validation outcome, which includes the encoding if valid or errors if invalid.
*
* @example
* const encoding = "base64";
* const result = emailValidator.isValidContentTransferEncoding(encoding);
* if (result.success) {
* console.log("Content transfer encoding is valid:", result.data);
* } else {
* console.error("Content transfer encoding validation errors:", result.error);
* }
*/

@@ -454,6 +641,16 @@ isValidContentTransferEncoding(encoding) {

/**
* Logs an error by throwing an EmailError with the provided Zod error details.
* Logs an error by throwing an `EmailError` with the provided Zod error details.
*
* @param error - The Zod error to be logged.
* @throws {EmailError} Throws an EmailError with the error message.
* @param {z.ZodError} error - The Zod error to be logged. Contains detailed error information from the Zod validation process.
* @throws {EmailError} Throws an `EmailError` with the error message and description based on the Zod error.
*
* @example
* try {
* const result = emailValidator.isValidData("Invalid data");
* if (!result.success) {
* emailValidator.logError(result.error);
* }
* } catch (e) {
* console.error("An error occurred:", e);
* }
*/

@@ -467,6 +664,19 @@ logError(error) {

/**
* Validates an attachment header using the AttachmentHeaderSchema.
* Validates an attachment header using the `AttachmentHeaderSchema`.
*
* @param attachmentHeader - The attachment header to be validated.
* @returns A Zod safe parse result containing the validation outcome.
* @param {z.infer<typeof AttachmentHeaderSchema>} attachmentHeader - The attachment header to be validated. Must conform to the `AttachmentHeaderSchema`.
* @returns {z.SafeParseReturnType<z.infer<typeof AttachmentHeaderSchema>, z.infer<typeof AttachmentHeaderSchema>>} A Zod safe parse result containing the validation outcome, which includes the attachment header if valid or errors if invalid.
*
* @example
* const attachmentHeader = {
* "Content-Type": "application/pdf",
* "Content-Disposition": "attachment; filename=\"example.pdf\"",
* "Content-Transfer-Encoding": "base64"
* };
* const result = emailValidator.isValidAttachment(attachmentHeader);
* if (result.success) {
* console.log("Attachment header is valid:", result.data);
* } else {
* console.error("Attachment header validation errors:", result.error);
* }
*/

@@ -483,2 +693,6 @@ isValidAttachment(attachmentHeader) {

*
* This property holds all the headers associated with the email. It includes fields such as "From", "To", "Subject",
* "Cc", "Bcc", "Date", and other standard email headers. The `HeadersType` defines the structure and types
* for each header field.
*
* @type {HeadersType}

@@ -506,5 +720,18 @@ */

/**
* Retrieves the validated email headers.
* Retrieves the email headers after validating them.
*
* @returns {HeadersType} The validated email headers.
* This method validates the current headers stored in the instance using the `isValidHeaders` method.
* If any validation errors are detected, they are logged, but the method still returns the parsed headers.
*
* @returns {HeadersType} The validated and parsed email headers.
*
* @example
* const emailBuilder = new EmailBuilder();
* emailBuilder.setHeaders({
* From: "sender@example.com",
* To: "recipient@example.com",
* Subject: "Test Email"
* });
* const headers = emailBuilder.getHeaders();
* console.log(headers);
*/

@@ -519,7 +746,36 @@ getHeaders() {

/**
* Sets the "From" header.
* Sets the headers for the email.
*
* @param {ValueType} From - The sender's email address.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method validates the provided headers using the `isValidHeaders` method.
* If the headers are invalid, it logs the error and still assigns the headers.
*
* @param {HeadersType} headers - The headers object to be set. This should contain key-value pairs representing the email headers.
* @returns {this} The current instance of the EmailBuilder class for method chaining.
*
* @example
* const emailBuilder = new EmailBuilder();
* emailBuilder.setHeaders({
* "From": "sender@example.com",
* "To": "recipient@example.com",
* "Subject": "Test Email"
* });
*/
setHeaders(headers) {
const { data: parsedHeaders, error: headersError } = this.isValidHeaders(headers);
if (headersError) this.logError(headersError);
this.headers = parsedHeaders;
return this;
}
/**
* Sets the "From" header of the email.
*
* This method allows you to specify the sender's email address by setting the "From" header.
*
* @param {ValueType} From - The sender's email address, typically in the format `"name@example.com"` or `"Name <name@example.com>"`.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setFrom("sender@example.com");
*/
setFrom(From) {

@@ -530,6 +786,15 @@ this.headers.From = From;

/**
* Sets the "To" header.
* Sets the "To" header of the email.
*
* @param {ValueType} To - The recipient's email address.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the recipient's email address. The "To" header indicates the primary recipient(s) of the email. It can include individual email addresses or multiple addresses separated by commas.
*
* @param {ValueType} To - The recipient's email address or addresses. This should be a string in the format `"name@example.com"` or `"Name <name@example.com>"`, or a comma-separated list of such addresses.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setTo("recipient@example.com");
*
* // For multiple recipients
* emailHeader.setTo("recipient1@example.com, recipient2@example.com");
*/

@@ -541,6 +806,14 @@ setTo(To) {

/**
* Sets the "Cc" header.
* Sets the "Cc" (Carbon Copy) header of the email.
*
* @param {ValueType} Cc - The carbon copy recipient's email address.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method allows you to specify additional recipients who will receive a copy of the email. The email address can be in a simple format or include a name.
*
* @param {ValueType} Cc - The carbon copy recipient's email address. This can be a single email address or multiple addresses separated by commas.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setCc("cc@example.com");
* // or with multiple addresses
* emailHeader.setCc("cc1@example.com, cc2@example.com");
*/

@@ -552,6 +825,14 @@ setCc(Cc) {

/**
* Sets the "Bcc" header.
* Sets the "Bcc" (Blind Carbon Copy) header of the email.
*
* @param {ValueType} Bcc - The blind carbon copy recipient's email address.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method allows you to specify additional recipients who will receive a blind copy of the email. Their addresses will be hidden from other recipients.
*
* @param {ValueType} Bcc - The blind carbon copy recipient's email address. This can be a single email address or multiple addresses separated by commas.
* @returns {this} The current instance of `EmailBuilderHeader`, enabling method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setBcc("bcc@example.com");
* // or with multiple addresses
* emailHeader.setBcc("bcc1@example.com, bcc2@example.com");
*/

@@ -563,6 +844,12 @@ setBcc(Bcc) {

/**
* Sets the "Date" header.
* Sets the "Date" header of the email.
*
* @param {string} Date - The date of the email.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method allows you to specify the date and time when the email is being sent. The date should be in a standard format that is compliant with RFC 5322.
*
* @param {string} Date - The date and time of the email in a string format. Example: `"Tue, 15 Aug 2024 10:00:00 +0000"`.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setDate("Tue, 15 Aug 2024 10:00:00 +0000");
*/

@@ -574,6 +861,12 @@ setDate(Date2) {

/**
* Sets the "Subject" header.
* Sets the "Subject" header of the email.
*
* @param {string} Subject - The subject of the email.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method allows you to specify the subject line of the email. The subject should be a concise summary of the email's content.
*
* @param {string} Subject - The subject of the email. Example: `"Meeting Reminder: Project Update"`.
* @returns {this} The current instance of `EmailBuilderHeader`, enabling method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setSubject("Meeting Reminder: Project Update");
*/

@@ -585,6 +878,12 @@ setSubject(Subject) {

/**
* Sets the "In-Reply-To" header.
* Sets the "In-Reply-To" header of the email.
*
* @param {EmailTypeString} InReplyTo - The email ID that this email is in reply to.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the email ID that this email is replying to. The "In-Reply-To" header is used to indicate the message ID of the original message in a reply or thread.
*
* @param {EmailTypeString} InReplyTo - The email ID or message ID that this email is in reply to. This should be a string representing the unique identifier of the original email.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setInReplyTo("<message-id@example.com>");
*/

@@ -596,6 +895,12 @@ setInReplyTo(InReplyTo) {

/**
* Sets the "MIME-Version" header.
* Sets the "MIME-Version" header of the email.
*
* @param {string} MIMEVersion - The MIME version of the email.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the MIME version used in the email. The "MIME-Version" header indicates the version of the MIME protocol that is being used for the email content.
*
* @param {string} MIMEVersion - The MIME version of the email, typically `"1.0"`. This indicates the version of the MIME protocol used.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setMIMEVersion("1.0");
*/

@@ -607,6 +912,12 @@ setMIMEVersion(MIMEVersion) {

/**
* Sets the "Content-Transfer-Encoding" header.
* Sets the "Content-Transfer-Encoding" header of the email.
*
* @param {ContentTransferEncoding} ContentTransferEncoding - The encoding for the email content.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the encoding used for the email content. The "Content-Transfer-Encoding" header describes how the email content is encoded for transmission.
*
* @param {ContentTransferEncoding} ContentTransferEncoding - The encoding for the email content, such as `"7bit"`, `"8bit"`, `"base64"`, or `"quoted-printable"`.
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setContentTransferEncoding("base64");
*/

@@ -618,6 +929,12 @@ setContentTransferEncoding(ContentTransferEncoding2) {

/**
* Sets the "Content-Type" header.
* Sets the "Content-Type" header of the email.
*
* @param {TupleUnion<MIMEType>} ContentType - The MIME type of the email content.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the MIME type of the email content. The "Content-Type" header indicates the media type and sub-type of the content, such as `"text/plain"` or `"text/html"`.
*
* @param {TupleUnion<MIMEType>} ContentType - The MIME type of the email content. This should be a string representing the type and sub-type of the content (e.g., `"text/html"` or `"multipart/alternative"`).
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setContentType("text/html");
*/

@@ -629,6 +946,12 @@ setContentType(ContentType) {

/**
* Sets the "Charset" header.
* Sets the "Charset" header of the email.
*
* @param {TupleUnion<typeof CharsetType>} Charset - The character set used in the email.
* @returns {this} The current instance of `EmailBuilderHeader`.
* This method specifies the character set used in the email. The "Charset" header indicates the encoding standard for the email content, such as `"utf-8"` or `"iso-8859-1"`.
*
* @param {TupleUnion<typeof CharsetType>} Charset - The character set used in the email. This should be a string representing the character encoding standard (e.g., `"utf-8"` or `"iso-8859-1"`).
* @returns {this} The current instance of `EmailBuilderHeader`, allowing for method chaining.
*
* @example
* const emailHeader = new EmailBuilderHeader();
* emailHeader.setCharset("utf-8");
*/

@@ -635,0 +958,0 @@ setCharset(Charset) {

2

package.json
{
"name": "@ahmedayob/email-toolkit",
"version": "0.1.11",
"version": "0.2.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "module": "dist/index.mjs",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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