Jin Hong
Jin Hong

Reputation: 192

{ [Error: timedout while connecting to smtp server] code: 4, smtp: undefined }

I am going to send mail in nodejs. So I have installed emailjs. I have configured the script as the followings.

emailjs = require('emailjs');

var server = emailjs.server.connect({
        user:"my gmail address",
        password:"gmail passs word",
        host:"smtp.gmail.com",
        ssl:true,
        port: 456
      });

 server.send({
          text: "message",
          from:"LLVC <my outlook mail>",
          to:"<my outlook mail>",
          subject:"Subject"
        },
        function (err, message) {
        console.log(err || message);
    });

But I got the errors

{ [Error: timedout while connecting to smtp server] code: 4, smtp: undefined }

I want to fix them. Thanks.

Upvotes: 3

Views: 3547

Answers (2)

Oliver
Oliver

Reputation: 193

Just in case someone else is looking for an answer. What worked for me was setting ssl to true and tls to false. Adding smtp port didn't help. With that been said the following are valid smtp ports: 25, 465, 587, and 2525. I hope this helps somebody else.

Upvotes: 3

GJKH
GJKH

Reputation: 1725

It's port 465, not 456.

If you tried configuring your SMTP server on port 465 (with SSL) and port 587 (with TLS), but are still having trouble sending mail, try configuring your SMTP to use port 25 (with SSL).

https://support.google.com/mail/answer/78775?hl=en

Upvotes: 3

Related Questions