0
votes

{ Error: connect ECONNREFUSED 127.0.0.1:587 at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14) code: 'ECONNECTION', errno: 'ECONNREFUSED', syscall: 'connect',
address: '127.0.0.1', port: 587, command: 'CONN' }

  const transporter = nodemailer.createTransport({
        service: 'smtp.gmail.com',
        auth: {
            user: 'email',
            pass: 'password '
        }
    });

I've switched on https://myaccount.google.com/lesssecureapps . What can it be ? I've tried ports - 465,25,463 ...it also isn't working . What should I do ?

1
Whats the cloud you're using ? - Kalana Demel
What do you mean(cloud)? - Andrey Radkevich

1 Answers

1
votes

You could try this transporter. Be sure to install Oauth2 using npm install oauth2and then requiring it in the file by using const Oauth2 = require('oauth2');

You can get the clientid, clientsecret, refreshtoken(be sure to set autorefresh on) and accestoken at https://console.developers.google.com/ and https://developers.google.com/oauthplayground/ this is for the gmail api.

  const transporter = nodemailer.createTransport({
  service: 'Gmail',
  auth: {
  type: 'OAuth2',
  user: 'yourmail',
  clientId: 'yourclientid',
  clientSecret: 'yourclientsecret',
  refreshToken: 'yourrefreshtoken',
  accessToken: 'youraccestoken',
  },
  });

Hope it helps!