title: 500 Internal Server Error,Request Timeout in nodejs resetpassword function
body: <p>I'm new in Nodejs and ES6 .and I wrote codes for login and register and resetpassword.I've got this 
  "This request takes too long to process, it is timed out by the server. If it should not be timed out, please contact administrator of this web site to increase 'Connection Timeout". when i try to call reset password in nodejs.I use es6 modules.How can i correct these code . </p>
  
  <p>my code :</p>
  
  <pre><code>   export const resetPasswordInit=(req,res)=&gt;{
    User.findOne({email:req.body.email},(err,user)=&gt;{
      if(err) throw err;
      if(user){
          const random=randomstring.generate(12);
          user.tempPassword=bcrypt.hashSync(random,10);
          user.tempPasswordTime=new Date();
          user.save((err,user)=&gt;{
              if (err)
              return res.status(400).send({
                  message:err
              });
                const transporter=nodemailer.createTransport({
                  host: 'mail.example.com',
                  port: 465,
                  secure: true, 
                    auth: {
                   user: "info@example.com",
                  pass: "example12"
                }
               });
  
                const mailOptions={
                    from :'Sender Name &lt;info@example.com&gt;s',
                    to : req.body.email,
                    subject:'Reset Password Request',
                    html: `
                    &lt;h1&gt;Hi,&lt;/h1&gt;
                    &lt;h2&gt;Here is your password reset key&lt;/h2&gt;
                    &lt;h2&gt;&lt;code contenteditable="false" style="font-weight:200;font-size:1.5rem;padding:5px 10px; background: #EEEEEE; border:0"&gt;${random}&lt;/code&gt;&lt;/h4&gt;
  
                    thanks,
                  `
                };
                       transporter.sendMail(mailOptions, function(error){
            if(error){
            console.log('Error occured');
           console.log(error.message);
       return;
     }
    else
    {
   console.log('Message sent successfully!');
   }
  
   });
          })
      }
      else{
          res.status(401).json({ message: 'failed. No user found!'});
      }
  });
  }
  </code></pre>