import type { SzPlatformClient } from '../classes.platformclient.js'; import * as plugins from '../plugins.js'; export type TServiceMailTlsMode = 'plain' | 'starttls' | 'implicitTls'; export interface IServiceMailSmtpCredentials { from: string; host: string; port: number; tlsMode: TServiceMailTlsMode; username: string; password: string; addressToken?: string; } export interface IServiceMailTypedCredentials { from: string; typedUrl: string; credentialId: string; credentialSecret: string; addressToken?: string; } export interface IServiceMailStatus { ready: boolean; from?: string; host?: string; port?: number; tlsMode?: TServiceMailTlsMode; typedUrl?: string; transport?: 'typedsocket' | 'smtp' | 'none'; usernameConfigured: boolean; passwordConfigured: boolean; typedCredentialConfigured?: boolean; smtpReady?: boolean; missing: string[]; } export interface IServiceMailAttachment { filename: string; contentType?: string; content: string | Uint8Array; } export interface IServiceMailSendOptions { /** Stable replay key for exact retries during dcrouter's 30-day idempotency window. */ idempotencyKey?: string; from?: string; to: string | string[]; cc?: string | string[]; bcc?: string | string[]; /** One bare mailbox address rendered as the authoritative Reply-To header by dcrouter. */ replyTo?: string; subject: string; text?: string; html?: string; headers?: Record; attachments?: IServiceMailAttachment[]; } export type TServiceMailSubmissionErrorCode = plugins.servezoneInterfaces.data.TMailSubmissionErrorCode; export declare class ServiceMailSubmissionError extends Error { readonly code: TServiceMailSubmissionErrorCode; constructor(code: TServiceMailSubmissionErrorCode, messageArg: string); } export interface IServiceMailSendResult { messageId?: string; spoolItemId?: string; accepted?: string[]; rejected?: string[]; response?: string; } export interface IServiceMailInboundMessage extends plugins.servezoneInterfaces.data.IMailInboundMessagePayload { from: string; to: string[]; receivedAtIso: string; } export interface IServiceMailInboundHandlerResult { accepted?: boolean; workAppMessageId?: string; message?: string; } export type IServiceMailInboundHandleResult = plugins.servezoneInterfaces.requests.mail.IReq_DeliverInboundMail['response']; export type TServiceMailInboundHandler = (messageArg: IServiceMailInboundMessage) => Promise | IServiceMailInboundHandlerResult | void; export declare class SzEmailConnector { platformClientRef: SzPlatformClient; private mailTypedSocket?; private mailTypedSocketUrl?; private mailTypedSocketPromise?; private mailTypedSocketAbortController?; private mailTypedSocketStatusSubscription?; private inboundHandler?; private inboundTypedHandlerRegistered; private inboundEndpointRegistrations; private inboundEndpointReplayPromise?; private readonly inboundEndpointReplayRetryDelaysMs; constructor(platformClientRefArg: SzPlatformClient); /** * Legacy platform-service email path. New service-mail code should use sendMail(). */ sendEmail(optionsArg: plugins.servezoneInterfaces.platform.email.IReq_SendEmail['request']): Promise; getServiceMailStatus(addressArg?: string): Promise; getServiceMailCredentials(addressArg?: string): Promise; sendText(optionsArg: Omit & { text: string; }): Promise; sendHtml(optionsArg: Omit & { html: string; }): Promise; sendMail(optionsArg: IServiceMailSendOptions): Promise; getMailDeliveryStatus(spoolItemIdArg: string, addressArg?: string): Promise; registerInboundHandler(handlerArg: TServiceMailInboundHandler, addressArg?: string): Promise; stop(): Promise; normalizeInboundMessage(payloadArg: unknown): IServiceMailInboundMessage; handleInboundPayload(payloadArg: unknown, handlerArg: TServiceMailInboundHandler): Promise; createInboundHandler(handlerArg: TServiceMailInboundHandler): (payloadArg: unknown) => Promise<{ accepted: boolean; workAppMessageId?: string; message?: string; }>; private ensureInboundTypedHandler; sendNotification(optionsArg: { toArg: string; subject: string; text: string; }): Promise; sendActionLink(optionsArg: { toArg: string; subject: string; text: string; }): Promise; private readMailEnv; private readMailEnvVar; private hasAnyMailEnvValue; private getServiceMailTypedCredentials; private getMailTypedSocket; private stopMailTypedSocket; private watchMailTypedSocketStatus; private handleMailTypedSocketStatus; private replayInboundEndpointRegistrationsWithRetry; private replayInboundEndpointRegistrationsWithRetryInner; private replayInboundEndpointRegistrationsOnce; private waitForInboundEndpointReplayRetry; private registerServiceMailEndpoint; private normalizeTypedSocketUrl; private normalizeTlsMode; private getMailEnvToken; private listToArray; private normalizeAttachmentContent; private asRecord; private normalizeHeaders; private extractHeader; }