forked from Soujanya2004/wanderlust-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a16740
commit bc87e2b
Showing
1 changed file
with
29 additions
and
0 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 |
---|---|---|
@@ -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; |