Terrtiary
Terrtiary

Reputation: 191

nodemailer failing with namecheap private email

I've searched this site for an answer that worked and have found nothing.

I'm trying to setup nodemailer and keep receiving this error:

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

Here's the setup code. I've tried with and without TLS (port: 465 and port: 587 with both combinations of secure: true and secure: false)

nodejs code:

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'
                });
            });
        }

Upvotes: 0

Views: 2218

Answers (1)

Paul Cozma
Paul Cozma

Reputation: 140

So it works just fine for me. This is my setup

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);
              }
            });`

And it works on secure port too.(465)

Upvotes: 5

Related Questions