@visulima/email
Version:
A comprehensive email library with multi-provider support, crypto utilities, and template engines
65 lines (64 loc) • 1.9 kB
TypeScript
import type { Buffer } from "node:buffer";
/**
* Detects MIME type from filename using mime package.
* Falls back to application/octet-stream if not found.
* @param filename The filename or path.
* @returns MIME type or application/octet-stream as fallback.
*/
export declare const detectMimeType: (filename: string) => string;
/**
* Generates a Content-ID for inline attachments.
* @param filename The filename to generate CID from.
* @returns A unique Content-ID string.
*/
export declare const generateContentId: (filename: string) => string;
/**
* Reads file and returns its content as Buffer.
* @param filePath Path to the file.
* @returns Buffer containing file content.
*/
export declare const readFileAsBuffer: (filePath: string) => Promise<Buffer>;
/**
* Attachment options for helper methods
*/
export interface AttachmentOptions {
/**
* Content-ID for inline attachments (used in HTML with cid:).
* If not provided and contentDisposition is 'inline', will be auto-generated.
*/
cid?: string;
/**
* Content disposition type.
* 'attachment' (default) or 'inline'.
*/
contentDisposition?: "attachment" | "inline";
/**
* MIME type of the attachment.
* If not provided, will be detected from filename.
*/
contentType?: string;
/**
* Content transfer encoding.
* Examples: 'base64', '7bit', 'quoted-printable'.
*/
encoding?: string;
/**
* Custom filename.
* Used when different from the file path.
*/
filename?: string;
/**
* Custom headers for this attachment.
*/
headers?: Record<string, string>;
}
/**
* Attachment data options (for raw data attachments)
*/
export interface AttachmentDataOptions extends AttachmentOptions {
/**
* Filename for the attachment.
* Required for raw data attachments.
*/
filename: string;
}