Files
smartmta/dist_ts/mail/delivery/classes.emailsendjob.d.ts
2026-02-10 15:54:09 +00:00

85 lines
2.1 KiB
TypeScript

import * as plugins from '../../plugins.js';
import { Email } from '../core/classes.email.js';
import type { UnifiedEmailServer } from '../routing/classes.unified.email.server.js';
export interface IEmailSendOptions {
maxRetries?: number;
retryDelay?: number;
connectionTimeout?: number;
tlsOptions?: plugins.tls.ConnectionOptions;
debugMode?: boolean;
}
export declare enum DeliveryStatus {
PENDING = "pending",
SENDING = "sending",
DELIVERED = "delivered",
FAILED = "failed",
DEFERRED = "deferred"
}
export interface DeliveryInfo {
status: DeliveryStatus;
attempts: number;
error?: Error;
lastAttempt?: Date;
nextAttempt?: Date;
mxServer?: string;
deliveryTime?: Date;
logs: string[];
}
export declare class EmailSendJob {
emailServerRef: UnifiedEmailServer;
private email;
private mxServers;
private currentMxIndex;
private options;
deliveryInfo: DeliveryInfo;
constructor(emailServerRef: UnifiedEmailServer, emailArg: Email, options?: IEmailSendOptions);
/**
* Send the email to its recipients
*/
send(): Promise<DeliveryStatus>;
/**
* Validate the email before sending
*/
private validateEmail;
/**
* Resolve MX records for the recipient domain
*/
private resolveMxRecords;
/**
* Attempt to deliver the email with retries
*/
private attemptDelivery;
/**
* Connect to a specific MX server and send the email using SmtpClient
*/
private connectAndSend;
/**
* Record delivery event for monitoring
*/
private recordDeliveryEvent;
/**
* Check if an error represents a permanent failure
*/
private isPermanentFailure;
/**
* Resolve MX records for a domain
*/
private resolveMx;
/**
* Log a message with timestamp
*/
private log;
/**
* Save successful email to storage
*/
private saveSuccess;
/**
* Save failed email to storage
*/
private saveFailed;
/**
* Delay for specified milliseconds
*/
private delay;
}