/** * SES operations handler * * Only used for: * - Sending OOO replies to external addresses * - Forwarding to external addresses */ import { SESClient, SendRawEmailCommand, } from '@aws-sdk/client-ses'; import { config } from '../config.js'; import { log } from '../logger.js'; export class SESHandler { private client: SESClient; constructor() { this.client = new SESClient({ region: config.awsRegion }); } /** * Send a raw MIME message via SES. * Returns true on success, false on failure (never throws). */ async sendRawEmail( source: string, destination: string, rawMessage: Buffer, workerName: string, ): Promise { try { await this.client.send( new SendRawEmailCommand({ Source: source, Destinations: [destination], RawMessage: { Data: rawMessage }, }), ); return true; } catch (err: any) { const code = err.name ?? err.Code ?? 'Unknown'; log( `⚠ SES send failed to ${destination} (${code}): ${err.message ?? err}`, 'ERROR', workerName, ); return false; } } }