ETIMEDOUT connection error using nodemailer in Nodejs Openshift application

I am facing some problems related to using the nodemailer module in a non-scalable application for my node.js machine in Openshift. As suggested in the documentation , I initialized the transport object and used the sendMail function. A simplified version of my code

var transporter = nodemailer.createTransport({
    service: 'Gmail',
    auth: {
        user: 'my.mail@gmail.com',
        pass: 'mypassword'
    }
});

var mail = {
    from: 'my.mail@gmail.com',
    to: 'test@mydomain.com',
    subject: 'Test mail',
    html: 'Test mail'
};

transporter.sendMail(mail, function(error, info) {
    if(error){
        console.log(error);
    }else{
        console.log(info);
    }
});

This code works correctly when I run it on my local computer, but when I try to execute it on the server, I get an ETIMEDOUTerror ETIMEDOUTas if the application cannot connect to the smtp server.

{ [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' }

I tried to increase the connection timeout setting, but I got the same results.

var transporter = nodemailer.createTransport({
    service: 'Gmail',
    auth: {
        user: 'my.mail@gmail.com',
        pass: 'mypassword'
    },
    connectionTimeout: 5 * 60 * 1000, // 5 min
});

Is there some kind of firewall or Openshift default setting or environment variable that I skip?

+5
2

, , , . - Gmail. Nodemailer

, Gmail , , OAuth2. Gmail , , , , , . , , - -, .

, XOAuth2, , .

+6

. Ubuntu ( Digital Ocean). 3 , auth2, ufw inactive, . Digital Ocean . TCP .

0

Source: https://habr.com/ru/post/1598352/


All Articles