UNPKG

universal_authentication

Version:

Seamless and Secure Authentication for Modern Web Applications: Easily integrate OTP-based email verification, Google OAuth, GitHub, Microsoft, and Okta login into your Node.js app. Modular, flexible, and database-agnostic, this package simplifies user au

32 lines (31 loc) 1.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.sendEmail = void 0; const nodemailer_1 = __importDefault(require("nodemailer")); const sendEmail = async (to, subject, text) => { try { // Create a transporter object using the Gmail SMTP service const transporter = nodemailer_1.default.createTransport({ service: "gmail", auth: { user: process.env.EMAIL_USER, pass: process.env.EMAIL_PASSWORD, }, }); // Define the email options await transporter.sendMail({ from: process.env.EMAIL_USER, to, subject, text, }); console.log(`Sent email: ${to}`); } catch (err) { console.error("Error sending email:", err); } }; exports.sendEmail = sendEmail;