Ian
Ian

Reputation: 354

nodemailer got EACCES while using SMTP

I'm trying to use nodemailer send the email. Below is the sample code.

const nodemailer = require('nodemailer');
let transporter = nodemailer.createTransport({
  host: '10.88.88.88', 
  port: 25, 
  secureConnection: false,
  auth: {
    user: 'user',  
    pass: 'pwd',
  }
});

let mailOptions = {
  from: '[email protected]', // sender address
  to: '[email protected]', // list of receivers
  subject: 'Hello', // Subject line
  html: '<b>Hello world?</b>' // html body
};

transporter.sendMail(mailOptions, (error, info) => {
  if (error) {
    return console.log(error);
  }
  console.log('Message sent: %s', info.messageId);
});

However I got the error below. It seems I could not access the server. The server is using smtp relay of IIS. What is the exact user/pass in auth here? The server window user account who has the right to access the smtp service? If I change user/pass to mailaddress/password, I got the same error info. If I remove auth, I still got the same error info. Or it is proxy issue?

{ Error: connect EACCES 10.88.88.88:25
  at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
  errno: 'EACCES',
  code: 'ECONNECTION',
  syscall: 'connect',
  address: '10.88.88.88,
  port: 25,
  command: 'CONN' }

The servers infra is like below:

node server <--> SMTP Relay IIS (10.88.88.88) <--> Mailserver

Upvotes: 2

Views: 1268

Answers (1)

Binita
Binita

Reputation: 26

Please check using port 587 instead of 25.

Upvotes: 1

Related Questions