UNPKG

@tanayvk/mailer

Version:

@adonisjs/mail without @adonisjs/core dependency.

73 lines (72 loc) 1.6 kB
import { debug_default } from "../../chunk-ZF2M7BIF.js"; import { MailResponse } from "../../chunk-CRXUSCKP.js"; import { __name } from "../../chunk-XE4OXN2W.js"; // src/transports/ses.ts import nodemailer from "nodemailer"; import SES from "@aws-sdk/client-ses"; var SESTransport = class { static { __name(this, "SESTransport"); } /** * SES config */ #config; /** * The nodemailer transport */ #transporter; constructor(config) { this.#config = config; } /** * Create transporter instance */ #createTransporter() { if (this.#transporter) { return this.#transporter; } const SESClient = new SES.SES(this.#config); this.#transporter = nodemailer.createTransport({ SES: { aws: SES, ses: SESClient }, sendingRate: this.#config.sendingRate, maxConnections: this.#config.maxConnections }); return this.#transporter; } /** * Send message */ async send(message, options) { const transporter = this.#createTransporter(); const mailOptions = Object.assign({}, message, { ses: options }); const sesResponse = await transporter.sendMail(mailOptions); return new MailResponse(sesResponse.messageId, sesResponse.envelope, sesResponse); } /** * Close transporter connection, helpful when using connections pool */ async close() { if (!this.#transporter) { return; } debug_default("closing ses transport"); this.#transporter.close(); this.#transporter = void 0; } }; export { SESTransport }; //# sourceMappingURL=ses.js.map