Skip to content

Commit 3616be5

Browse files
author
sourabh
committed
[Email]-work on nodemailer for sending
1 parent 12ed153 commit 3616be5

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

.env

+5
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ CLOUDINARY_NAME = djqf9vhkq
99
CLOUDINARY_API_KEY = 333799583579346
1010
CLOUDINARY_API_SECRET = NQvSauVhU6fjJ5Wrd_GDqMHTVu4
1111

12+
13+
SMTP_HOST= sandbox.smtp.mailtrap.io
14+
SMTP_PORT= 2525
15+
SMTP_USER= 950917e0029581
16+
SMTP_PASS= ********4462

tracking_project/map_project.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,13 @@ Note: ALSO Allow PASSWORD Body itself
161161
162162
163163
----------------------------------SECTION
164-
@LOCATION: 🗃️CONTROLLER/user.js
165-
@TITLE:->
166-
@ABOUT:->
167-
164+
@LOCATION: 🗃️utils/emailHelper
165+
@TITLE:-> SENDING EMAIL
166+
@ABOUT:-> nodemailer & mailtrap
168167
@OVERVIEW@
168+
🔗✈️https://nodemailer.com/about/
169+
🔗✈️https://mailtrap.io/home
170+
🔗✈️https://courses.learncodeonline.in/learn/home/Pro-Backend-Developer-course/section/239125/lesson/1409394?
169171
170172
171173
*/

utils/emailHelper.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const nodemailer = require("nodemailer");
2+
3+
const mailHelper = async (options) => {
4+
const transporter = nodemailer.createTransport({
5+
host: process.env.SMTP_HOST,
6+
port: process.env.SMTP_PORT,
7+
auth: {
8+
user: process.env.SMTP_USER,
9+
pass: process.env.SMTP_PASS,
10+
},
11+
});
12+
13+
const message = {
14+
from: 'johndown@.dev', // sender address
15+
to: options.email, // list of receivers
16+
subject: options.subject, // Subject line
17+
text: options.message, // plain text body
18+
};
19+
await transporter.sendMail(message);
20+
};
21+
22+
module.exports = mailHelper;

0 commit comments

Comments
 (0)