UNPKG

@jubayer_shuvo/mailer-js

Version:

A lightweight and easy-to-use Node.js mailer utility supporting TypeScript and JavaScript.

22 lines (21 loc) 710 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); async function sendMail({ apiKey, to, subject, text, }) { const response = await fetch("https://mailer-js.vercel.app/api/send-mail-external", { method: "POST", headers: { "api-key": apiKey, "Content-Type": "application/json", }, body: JSON.stringify({ apiKey, to, subject, text }), }); if (!response.ok) { const error = await response.text(); throw new Error(`Failed to send email: ${response.status} ${error}`); } return { success: true }; } exports.default = sendMail; if (typeof module !== "undefined") { module.exports = sendMail; }