3

I need to check whether my email address has valid host, exist for example someone@yahoo.com might return valid meanwhile some@yahozzz.com might return invalid (because invalid host)

I stumbled upon a code in git for golang that satisfy my needs for that https://github.com/badoux/checkmail, but currently at the moment i'm looking for the solution in javascipt, any help will be appreciated.

P.S. : I am using this code as a script inside my HTML

DemiDust
  • 221
  • 2
  • 14
  • 2
    Is there a reason you do not want to use regex? – Marvin Fischer Jan 03 '19 at 10:33
  • you should definitly use regex. if this is some kind of homework you should think about this yourself. – Philipp Sander Jan 03 '19 at 10:34
  • no no, what i am trying to figure out is not format checking for the email but rather to check whether the email really exist or valid (some@yahoo.com is valid while some@yahozzzo.com might return invalid), i edited my answer so it will become more clear – DemiDust Jan 03 '19 at 10:37
  • You need to determine if an MX record exists in DNS for the hostname, which means you need to make a DNS query, but JavaScript has no built-in mechanisms for I/O and depends on the host environment to provide such APIs … and you haven't said what host environment you are using. Node.js? WSH? An HTML document loaded in a browser? A browser extension? etc. – Quentin Jan 03 '19 at 10:42
  • I have added the environment for it, thanks @Quentin – DemiDust Jan 03 '19 at 10:44

1 Answers1

0

Actually to verify that an email exists and is active you have to send a message to the email server and check the response. That cannot be done entirely in javascript although you can rely on a service instead than on your backend like this

Mosè Raguzzini
  • 12,776
  • 26
  • 36