Skip to main content

Send Verification Mail on User Registration Node Js without SSL certificate Solution - self signed certificate in certificate chain nodejs

First do npm install nodemailer   & then import it in backend code   

========== Backend Code ===

create EmailAPI.js file in your router folder & then import it to your IndexRouter.js file 

// EmailAPI.js 

import nodemailer from 'nodemailer';


var sendMail=(email,password,token)=>{

   process.env.NODE_TLS_REJECT_UNAUTHORIZED='0'


var transporter = nodemailer.createTransport({

  service: 'gmail',

  auth: {

    user: 'vasubirla@gmail.com',

    pass: 'mtvrqzmxlarnrg9h' // Create your own temporary password from Google setting  

  }

});


var mailOptions = {

  from: 'vasubirla@gmail.com',

  to: email,

  subject: 'Verification Mail MyApp',

  html: "<h1>Welcome To MyApp</h1><p>you have successfully register to our app , your login credentials are attached below</p><h3>Email : "+email+"</h3><h3>Password : "+password+"<h3>OTP for account verification is </h3>"  + "<h1 style='font-weight:bold;'>" + otp +"</h1>"+"</h3><br><h2>Click on the link below to verify your account</h2>http://localhost:3000/verifyUser/"+email+'/'+token

};


transporter.sendMail(mailOptions, function(error, info){

  if (error) {

    console.log(error);

  } else {

    console.log('Email sent: ' + info.response);

  }

}); 


}


export default sendMail;

============================================================end EmailAPI,js


// IndexRouter.js Start 

router.post("/register",(req,res)=>{

      IndexController.registerUser(req.body).then((result)=>{

    var token = result.token;

      sendEmail(req.body.email,req.body.password,token);

      res.render("register",{"output":"User register successfully..."});

         

 }).catch((err)=>{

       res.render("register",{"output":err});

    //console.log(err);

 });


});


=========================================end IndexRouter.js


   IndexController.registerUser(req.body).then((result)=>{


      res.render("register",{"output":"User register successfully..."});

 }).catch((err)=>{

    res.render("register",{"output":err});

 });




 //res.json(req.body);

});

Comments

Popular posts from this blog

Part 15- What is Repeater (Networking Devices)- Computer Networking- CCNA

Repeater  hello friends i am Vasu Birla and today i am starting new segment of CCNA computer networking  its a Networking Devices. we will discuss every important Devices used in networks. Repeater is a first networking devices. What is Repeater  Repeater is a device that receives signals and re-transmits by amplifying or regenerating signals. Repeater has two port one is for receive signals from previous network and second port is for retransmit signals to the next extended network. Two Port Repeater Repeater is a device which is used to Regenerate or replicate signal (Pichhe se aa rahe signal ko regenerate karke ya amplify karke aage strong signals bhej sakte he) Analog and digital both type of signals can be retransmitted by repeater. Here there is difference between regeneration and amplifying.  Amplification means , received signals will be amplified as it is , whether there are impurities in signals  and Regeneration means repeate...

GitHub Repo Collaboration Work on single project

 =============================================== To collaborate effectively with your friend on the same project, you should use Git branches to manage different lines of development. Here's a step-by-step procedure you can follow to streamline collaboration: 1. Create Separate Branches for Each Developer Create a New Branch for Your Friend: On your local repository, create a new branch for your friend. For example if your friend name is kilvish , if you want to create a branch named kilvish , you would run: make sure you would be on main branch already   command->  git checkout -b kilvish git push origin kilvish 2. Set Up Your Friend’s Environment( On your Friend's System )  at kilvish side  run ->  Clone the Repository (if not already done): If your friend hasn’t cloned the repository yet, they should do so: command ->  git clone https://github.com/Vasu-Birla/your-repo.git   // your your main clone line  Fetch All Bran...

Part 19- Router (Networking Devices)- Computer Networking- CCNA

Hello friends...i am Vasu Birla and today will discuss about the most important Networking Device ..Router.  so let's start... ROUTER Router is a device which connect two or more networks together, which is why router is also known is Inter-networking device also. Inter-networking means two or more networks are connected together with the help of router. one more thing router is just like a computer  but it is designed for routing only, our computer can be router also but that are software router while hardware router which are specialize for routing is more efficient and fast than software router.  There is a Operating System installed on router which get moves data from one network to another network with the help of routing table.  Router does work on Network layer or Layer 3 of the OSI model.  Cisco Router There many companies which manufacture Router but main companies are - Cisco , Juniper , HP, 3com and Nortel  ...