From d0252e34c612c841758f836cc5c617d5f062326e Mon Sep 17 00:00:00 2001 From: Lavan Vivekanandasarma Date: Fri, 30 Aug 2024 22:44:38 -0400 Subject: [PATCH] Used app password --- email.ts | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/email.ts b/email.ts index 792f232..3e485e4 100644 --- a/email.ts +++ b/email.ts @@ -1,14 +1,6 @@ const nodemailer = require("nodemailer"); -// const dkim = require('nodemailer-dkim'); - import { NextFunction } from "express"; -// const dkimOptions = { -// domainName: 'example.com', -// keySelector: 'selector1', -// privateKey: '' -// } - export type EmailOptions = { to?: string; subject?: string; @@ -39,20 +31,18 @@ export const sendEmail = ({ callback, }: EmailOptions) => { const transporter = nodemailer.createTransport({ - host: "smtp.gmail.com", - port: 587, + service: "gmail", auth: { - user: process.env.SMTP_EMAIL_EMAIL, - pass: process.env.SMTP_EMAIL_PASSWORD, + user: "membership@datasciencegt.org", // Your Gmail address + pass: "pocc lsum rneu dusu", // Your app password }, }); - // if (Array.isArray(to)) { - // to = to.join(", "); - // } + transporter.verify().then().catch(next); + transporter .sendMail({ - from: `"${process.env.SMTP_EMAIL_USERNAME}" `, // sender address + from: `"DSGT" `, // sender address to: to, // list of receivers subject: subject, // Subject line text: text, // plain text body @@ -62,6 +52,7 @@ export const sendEmail = ({ attachments: attachments, }) .then((info: any) => { + // console.log(`Email sent from "DSGT" `); // sender address if (callback) { callback(); }