27 lines
870 B
TypeScript
27 lines
870 B
TypeScript
import env from "../enviroment/env";
|
|
import {UserInterface} from "../models/user"
|
|
import sgMail from "@sendgrid/mail";
|
|
|
|
const sendVerificationEmail = async (user: UserInterface, emailToken: string) => {
|
|
|
|
const apiKey: any = env.sendgridKey;
|
|
const sendgridEmail:any = env.sendgridEmail;
|
|
const url = env.remoteURL + `/verify-email/${emailToken}`
|
|
|
|
// console.log("send grid api key", apiKey)
|
|
// console.log("send grid email", sendgridEmail);
|
|
// console.log("send grid verify url", url)
|
|
sgMail.setApiKey(apiKey);
|
|
|
|
const msg = {
|
|
to: user.email,
|
|
from: sendgridEmail,
|
|
subject: "myDrive Email Verification",
|
|
text: `Please navigate to the following link to verify your email address: ${url}`
|
|
}
|
|
|
|
await sgMail.send(msg);
|
|
//console.log("Send grid email sent");
|
|
}
|
|
|
|
export default sendVerificationEmail; |