我已经在该网站上搜索了有效的答案,却一无所获。

我正在尝试设置nodemailer并继续收到此错误:

{"code":"EENVELOPE","command":"API"}


这是设置代码。我试过使用和不使用TLSport: 465port: 587以及secure: truesecure: false的两种组合)

nodejs代码:

function(resetToken, user, done) {
            let smtpConfig = nodemailer.createTransport({
                host: 'mail.privateemail.com',
                port: 587,
                secure: false,
                auth: {
                    user: 'email',
                    pass: 'pass'
                }
            });
            let mailOptions = {
                to: user.email,
                from: 'email',
                subject: 'Password Reset For app',
                text: 'Reset this'
            };
            smtpConfig.sendMail(mailOptions, function(err, info) {
                if(err) {
                    res.json({
                        'message': err,
                        'info': info
                    });
                }
                res.json({
                    'message': 'Click the link in the email we just sent to reset your password'
                });
            });
        }

最佳答案

所以对我来说很好。这是我的设置

var transporter = `nodemailer.createTransport({
  host: 'mail.privateemail.com',
  port: 587,
  secure: false,
  auth: {
      user: 'user',
      pass: 'pass'
  }
});
var mailOptions = {
              from: '[email protected]',
              to: req.body.email,
              subject: 'Hi there',
              text: 'I work'
            };
transporter.sendMail(mailOptions, function(error, info){
              if (error) {
                console.log(error);
              } else {
                console.log('Email sent: ' + info.response);
              }
            });`


它也可以在安全端口上运行。(465)

10-06 08:11