-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathotp.js
More file actions
31 lines (27 loc) · 778 Bytes
/
otp.js
File metadata and controls
31 lines (27 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user:process.env.EMAIL,
pass:process.env.PASSWORD
}
});
function generateOTP(){
return Math.floor(100000 + Math.random() * 900000);
}
async function sendOTP(email,otp) {
try{
const result = await transporter.sendMail({
from: 'no-reply@musicali',
to:email,
subject:"OTP for Email Verification",
html: `<h1 style="text-align:center">Your OTP is ${otp}</h1>
<p style="text-align:center">It is only valid for 5 minutes</p>`,
});
console.log(result);
}
catch(err){
console.log(err);
}
}
module.exports={sendOTP,generateOTP}