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

26 lines (23 loc) 661 B
import nodemailer from "nodemailer"; export const sendEmail = async (to: string, subject: string, text: string) => { try { // Create a transporter object using the Gmail SMTP service const transporter = nodemailer.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); } };