nodemailer使用namecheap私有电子邮件失败

时间:2017-09-10 01:51:12

标签: node.js nodemailer namecheap

我在这个网站上搜索了一个有效且没有找到任何答案的答案。

我试图设置nodemailer并继续收到此错误:

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

这是设置代码。我已尝试使用TLS port: 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'
                });
            });
        }

1 个答案:

答案 0 :(得分:2)

所以它适用于我。这是我的设置

var transporter = `nodemailer.createTransport({
  host: 'mail.privateemail.com',
  port: 587,
  secure: false,
  auth: {
      user: 'user',
      pass: 'pass'
  }
});
var mailOptions = {
              from: 'contact@domain.com',
              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)