-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from DataScience-GT/SMTP_Fix
Changed Mailing Service
- Loading branch information
Showing
1 changed file
with
7 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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 | ||
|
@@ -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(); | ||
} | ||
|