| Current Path : /var/node/inatote/Inatote-Backend/helpers/ |
| Current File : //var/node/inatote/Inatote-Backend/helpers/twilio-send_grid.js |
import sgMail from "@sendgrid/mail";
import config from "../config.js";
const sendEmail = async({ senderMail, templateId , text , templateData}) => {
sgMail.setApiKey(config.app.sendGridApiKey);
var msg = {
to: senderMail, // Change to your recipient
from: "sarooshsyed@inatote.ca", // Change to your verified sender
};
if(templateId){
msg = {
...msg,
// subject: 'Sending wit SendGrihd is Fun',
// // text: 'and easy to do anywhere, even with Node.js',
// // html: '<strong>and easy to do anywhere, even with Node.js</strong>',
templateId: templateId,
dynamic_template_data: templateData
}
}
if(text){
msg = {
...msg,
subject: 'Inatote',
text: text,
}
}
console.log("MSG" , msg);
let emailStatus = sgMail.send(msg)
.then((e) => {
console.log('Email sent',e)
return e
})
.catch((error) => {
console.error(error)
console.log("ERRor" , error);
return error
});
return emailStatus
}
export default sendEmail;