没有收到来自sendgrid-Node JS的邮件。

问题描述 投票:0回答:1

我通过sendgrid验证了我的 "发件人",但仍然没有收到任何邮件。也没有错误日志,这可以帮助我找出问题所在。下面是相关的代码片段。

exports.postSignup = (req, res, next) => {
  const name = req.body.name;
  const email = req.body.email;
  const password = req.body.password;
  const confirmPassword = req.body.confirmPassword;
  User.findOne({
    email: email
  })
  .then(userDoc => {
    if (userDoc) {
      req.flash('emailError', 'Email ID already exists!');
      return res.redirect('/signup');
    }
    return bcrypt.hash(password, 12)
    .then(hashedPassword => {
      const user = new User({
        name: name,
        email: email,
        password: hashedPassword,
        cart: {
          items: [],
          totalPrice: 0
        }
      });
      return user.save();
    })
    .then(result => {
      res.redirect('/login');
      return transporter.sendMail({
        to: email,
        from: '[email protected]',
        subject: 'Signup succeeded',
        html: '<h1>You successfully signed up!</h1>'
      }); 
    })
    .catch(err => console.log(err));
  })
  .catch(err => console.log(err));
};

知道这里发生了什么吗?

node.js email sendgrid
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.