Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emailjs throwing a getaddrinfo ENOTFOUND smtp.gmail.com error #136

Closed
saicharanp opened this issue Dec 11, 2015 · 16 comments
Closed

emailjs throwing a getaddrinfo ENOTFOUND smtp.gmail.com error #136

saicharanp opened this issue Dec 11, 2015 · 16 comments

Comments

@saicharanp
Copy link

var email = require('emailjs/email');

var server = email.server.connect({
        user:    "[email protected]",
        password:"password22",
        host:    "smtp.gmail.com ",
        ssl:     true,
        port : 465
    });
    server.send({
        text:    "i hope this works",
        from:    "user <[email protected]>",
        to:      "user <[email protected]>",
        cc:      "",
        subject: "testing emailjs"
    }, function(err, message) { console.log(err || message); });

I am getting the following error in console

{ [Error: connection encountered an error]
  code: 5,
  previous:
   { [Error: getaddrinfo ENOTFOUND smtp.gmail.com ]
     code: 'ENOTFOUND',
     errno: 'ENOTFOUND',
     syscall: 'getaddrinfo',
     hostname: 'smtp.gmail.com ' },
  smtp: undefined }
@eleith
Copy link
Owner

eleith commented Dec 24, 2015

i can not replicate.

this error "getaddrinfo ENOTFOUND smtp.gmail.com" likely means your DNS is not resolving smtp.gmail.com for some reason.

try on another machine to verify that this is indeed the case

@eleith eleith closed this as completed Dec 24, 2015
@ashutoshdev-zz
Copy link

Hello ,
I am also getting error
Server up: http://localhost:3300
{ [Error: getaddrinfo ENOTFOUND 1234 1234:465]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: '1234',
host: '1234',
port: 465 }

@XiSmartElf
Copy link

same here

3 similar comments
@IveSix
Copy link

IveSix commented Nov 17, 2016

same here

@wujunchuan
Copy link

same here

@AlwaBysi
Copy link

same here

@wujunchuan
Copy link

After that I solved this problem.
You can make sure your DNS can resolving the Email server address.

just have a try

nslookup smtp.gmail.com

@siteantipas
Copy link

I have tried the above code
nslookup smtp.gmail.com
in command prompt, my machine can resolve to it but it still giving that error.

@gelinger777
Copy link

just for those who could be having this error. Please check that you did not copy by mistake a white-space before or after the value of the SMTP server host. In that case DNS resolver fails.

@zackschuster
Copy link
Collaborator

@eleith do you think we should trim the host etc. strings?

@gelinger777
Copy link

gelinger777 commented Apr 30, 2020

@zackschuster yes, a basic trim whitespaces before after and remove unallowed characters for domain name would be good. Sorry for answering instead of @eleith

@eleith
Copy link
Owner

eleith commented Apr 30, 2020

@zackschuster / @gelinger777 good point.

i think it depends on what is the best way to define the intent of the user input in this API.

there are two approaches

  1. treat input as suggestive and the library fixes input when there is some level of confidence

  2. treat input as determinant and provide better error messaging like did you mean X instead of Y ?

if we isolate this treatment to the host, trimming feels appropriate / high confidence enough without having to wade deeper into what to do with all the other input handling =]

@zackschuster
Copy link
Collaborator

@eleith i agree, the first change should be limited to host & more changes can be explored later if desired or necessary. off the top of my head i think we would want to evaluate the existential checks next (e.g. !str or str1 || str2).

@zackschuster
Copy link
Collaborator

@eleith should we move forward with host trimming?

@eleith
Copy link
Owner

eleith commented May 26, 2020

sounds good!

@zackschuster
Copy link
Collaborator

@eleith done in b3fa0ba. i chose to do it the more verbose way to leave user configuration intact, in case changing that would confuse anyone :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants