Skip to content

Commit

Permalink
Adding mailSenderFile:
Browse files Browse the repository at this point in the history
  • Loading branch information
harshbhar0629 committed Oct 30, 2024
1 parent 8a16740 commit bc87e2b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions utils/mailSender.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/** @format */

const nodemailer = require("nodemailer");
require("dotenv").config();

const mailSender = async (email, title, body) => {
try {
let transporter = nodemailer.createTransport({
host: process.env.MAIL_HOST,
auth: {
user: process.env.MAIL_USER,
pass: process.env.MAIL_PASS,
},
});

// send mail
let info = await transporter.sendMail({
from: `Wanderlust - by Sounjanya`,
to: email,
subject: `${title}`,
html: `${body}`,
});
console.log(info);
} catch (err) {
console.log("Error in sending mail");
}
};

module.exports = mailSender;

0 comments on commit bc87e2b

Please sign in to comment.