UNPKG

@adonisjs/mail

Version:

Mail provider for adonis framework and has support for all common mailing services to send emails

55 lines (54 loc) 1.21 kB
import { MailResponse } from "../../chunk-CRXUSCKP.js"; import { debug_default } from "../../chunk-ZF2M7BIF.js"; import { __name } from "../../chunk-XE4OXN2W.js"; // src/transports/smtp.ts import nodemailer from "nodemailer"; var SMTPTransport = class { static { __name(this, "SMTPTransport"); } #config; #transporter; constructor(config) { this.#config = config; } /** * Create transporter instance */ #createTransporter() { if (this.#transporter) { return this.#transporter; } this.#transporter = nodemailer.createTransport(this.#config); return this.#transporter; } /** * Send message */ async send(message) { const transporter = this.#createTransporter(); const smtpResponse = await transporter.sendMail(message); return new MailResponse(smtpResponse.messageId, smtpResponse.envelope, smtpResponse); } /** * Close transporter connection, helpful when using connections pool */ async close() { if (!this.#transporter) { return; } debug_default("closing smtp transport"); this.#transporter.close(); this.#transporter = void 0; } }; export { SMTPTransport }; //# sourceMappingURL=smtp.js.map