Skip to content

Commit

Permalink
Merge pull request #53 from DataScience-GT/SMTP_Fix
Browse files Browse the repository at this point in the history
Changed Mailing Service
  • Loading branch information
lavanv11 authored Sep 2, 2024
2 parents 16a8f35 + d0252e3 commit f768635
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions email.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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: "[email protected]", // 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}" <[email protected]>`, // sender address
from: `"DSGT" <[email protected]>`, // sender address
to: to, // list of receivers
subject: subject, // Subject line
text: text, // plain text body
Expand All @@ -62,6 +52,7 @@ export const sendEmail = ({
attachments: attachments,
})
.then((info: any) => {
// console.log(`Email sent from "DSGT" <[email protected]>`); // sender address
if (callback) {
callback();
}
Expand Down

0 comments on commit f768635

Please sign in to comment.