import { SentlyError } from "../core/errors.js"; import type { MailOptions, SendResult, SMTPAuth, SocketAdapter, TLSOptions, Transport, VerifyResult } from "../core/types.js"; /** Default SMTP host for a local Mailpit instance. */ export declare const MAILPIT_DEFAULT_HOST = "localhost"; /** Default SMTP port for a local Mailpit instance. */ export declare const MAILPIT_DEFAULT_PORT = 1025; /** Default web UI / REST API base URL for a local Mailpit instance. */ export declare const MAILPIT_DEFAULT_API_URL = "http://localhost:8025"; /** Mailpit development transport configuration. */ export interface MailpitConfig { /** SMTP hostname. Default: `"localhost"`. */ host?: string; /** SMTP port. Default: `1025`. */ port?: number; /** Use implicit TLS on connect. Default: `false` (Mailpit is plain SMTP). */ secure?: boolean; /** * Refuse AUTH over a non-TLS connection. * Default: `false` so optional local SMTP auth works without TLS. */ requireTLS?: boolean; /** Optional SMTP authentication (Mailpit can accept any credentials). */ auth?: SMTPAuth; /** TLS options when STARTTLS or implicit TLS is enabled. */ tls?: TLSOptions; /** Socket connect timeout in milliseconds. */ connectionTimeout?: number; /** Runtime socket adapter. Auto-detected on first send when omitted. */ adapter?: SocketAdapter; /** * Mailpit web UI / REST API base URL (no trailing slash). * Default: `"http://localhost:8025"`. */ apiUrl?: string; /** Basic auth for the Mailpit UI/API when the instance requires it. */ apiAuth?: { user: string; pass: string; }; } /** Address object returned by the Mailpit REST API. */ export interface MailpitAddress { /** Display name, may be empty. */ Name: string; /** Email address. */ Address: string; } /** Summary row from `GET /api/v1/messages` / `GET /api/v1/search`. */ export interface MailpitMessageSummary { /** Mailpit message id. */ ID: string; /** MIME Message-ID. */ MessageID: string; /** Sender. */ From: MailpitAddress; /** Recipients. */ To: MailpitAddress[]; /** Subject line. */ Subject: string; /** ISO created timestamp. */ Created: string; /** Attachment count. */ Attachments: number; /** Whether the message has been read in the UI. */ Read: boolean; /** Short plain-text snippet. */ Snippet: string; } /** Response from `GET /api/v1/messages` / `GET /api/v1/search`. */ export interface MailpitMessageList { /** Total messages stored (or matching the search). */ total: number; /** Unread message count. */ unread: number; /** Messages returned in this page. */ count: number; /** Message summaries (newest first). */ messages: MailpitMessageSummary[]; } /** Full message from `GET /api/v1/message/{id}`. */ export interface MailpitMessage { /** Mailpit message id. */ ID: string; /** MIME Message-ID. */ MessageID: string; /** Sender. */ From: MailpitAddress; /** Recipients. */ To: MailpitAddress[]; /** CC recipients. */ Cc?: MailpitAddress[]; /** BCC recipients. */ Bcc?: MailpitAddress[]; /** Subject line. */ Subject: string; /** Plain-text body. */ Text: string; /** HTML body. */ HTML: string; /** ISO created timestamp. */ Date: string; /** Attachment count. */ Attachments: number; } /** * Message headers from `GET /api/v1/message/{id}/headers`. * Keys are header names; values are one or more header lines. */ export type MailpitHeaders = Record; /** Aggregate counts from {@link MailpitHtmlCheck}. */ export interface MailpitHtmlCheckTotal { /** Node count in the HTML. */ Nodes: number; /** Partially supported checks. */ Partial: number; /** Fully supported checks. */ Supported: number; /** Total checks run. */ Tests: number; /** Unsupported checks. */ Unsupported: number; } /** One warning row from Mailpit’s HTML checker. */ export interface MailpitHtmlCheckWarning { /** Warning category. */ Category: string; /** Human-readable description. */ Description: string; /** Keyword summary. */ Keywords: string; /** Title. */ Title: string; /** caniemail.com URL when present. */ URL: string; /** Per-platform support breakdown. */ Score: { Found: number; Partial: number; Supported: number; Unsupported: number; }; } /** Response from `GET /api/v1/message/{id}/html-check`. */ export interface MailpitHtmlCheck { /** Platforms covered by the check. */ Platforms: Record; /** Aggregate support totals. */ Total: MailpitHtmlCheckTotal; /** Individual warnings. */ Warnings: MailpitHtmlCheckWarning[]; } /** One link result from Mailpit’s link checker. */ export interface MailpitLinkCheckItem { /** Status label (e.g. `"OK"`, `"Error"`). */ Status: string; /** HTTP status code when available. */ StatusCode: number; /** Checked URL. */ URL: string; } /** Response from `GET /api/v1/message/{id}/link-check`. */ export interface MailpitLinkCheck { /** Number of failing links. */ Errors: number; /** Per-URL results. */ Links: MailpitLinkCheckItem[]; } /** Options for {@link MailpitTransport.messages} / {@link MailpitTransport.search}. */ export interface MailpitMessagesOptions { /** Max messages to return. */ limit?: number; /** Pagination offset. */ start?: number; } /** Options for {@link MailpitTransport.linkCheck}. */ export interface MailpitLinkCheckOptions { /** Follow HTTP redirects when checking links. Default: `false`. */ follow?: boolean; } /** Error thrown when the Mailpit REST API returns a non-success response. */ export declare class MailpitError extends SentlyError { readonly statusCode: number; readonly apiError: unknown; /** Creates a Mailpit API error with status code (`0` = network/connect failure). */ constructor(message: string, statusCode: number, apiError: unknown); } /** * Development transport for [Mailpit](https://github.com/axllent/mailpit). * * Sends via SMTP (defaults: `localhost:1025`) and exposes REST helpers for * listing, searching, reading, checking, and deleting captured messages. */ export declare class MailpitTransport implements Transport { readonly provider = "mailpit"; private readonly host; private readonly port; private readonly secure; private readonly requireTLS; private readonly auth?; private readonly tls?; private readonly connectionTimeout?; private readonly adapter?; private readonly apiUrl; private readonly apiAuth?; private smtp; /** Creates a Mailpit transport with local-dev defaults. */ constructor(config?: MailpitConfig); /** Web UI base URL (same origin as the REST API). */ get webUrl(): string; /** Sends an email to Mailpit over SMTP. */ send(options: MailOptions): Promise; /** Verifies SMTP connectivity to Mailpit. */ verify(): Promise; /** Closes the underlying SMTP adapter if connected. */ close(): Promise; /** * Lists captured messages via `GET /api/v1/messages`. * Newest messages appear first. */ messages(options?: MailpitMessagesOptions): Promise; /** * Searches captured messages via `GET /api/v1/search`. * Query syntax matches the Mailpit UI (`subject:`, `to:`, `tag:`, …). */ search(query: string, options?: MailpitMessagesOptions): Promise; /** * Fetches a full message via `GET /api/v1/message/{id}`. * Pass `"latest"` for the newest message. */ getMessage(id: string): Promise; /** * Fetches message headers via `GET /api/v1/message/{id}/headers`. * Pass `"latest"` for the newest message. */ getHeaders(id: string): Promise; /** * Runs Mailpit’s HTML/CSS client-compatibility check via * `GET /api/v1/message/{id}/html-check`. * Pass `"latest"` for the newest message. */ htmlCheck(id: string): Promise; /** * Runs Mailpit’s link checker via `GET /api/v1/message/{id}/link-check`. * Pass `"latest"` for the newest message. */ linkCheck(id: string, options?: MailpitLinkCheckOptions): Promise; /** * Sets read status via `PUT /api/v1/messages`. * Pass an empty `ids` array to update every message in the mailbox. */ setRead(ids: string[], read: boolean): Promise; /** * Deletes messages by id via `DELETE /api/v1/messages`. * Pass an empty array (or call {@link deleteAll}) to clear the inbox. */ deleteMessages(ids: string[]): Promise; /** Deletes every captured message. */ deleteAll(): Promise; private listPath; private encodeId; private getSmtp; private apiHeaders; private apiFetch; private apiJson; private apiOk; }