syrusakbary / validate_email

Validate_email verify if an email address is valid and really exists
Other
579 stars 232 forks source link

Always returning None #51

Open victorjabur opened 8 years ago

victorjabur commented 8 years ago

For 2 first validations, it responds None, should be True or False ?

For 2 last validations, it responds always True, it is not checking if e-mail exists or not.

from validate_email import validate_email

is_valid_1 = validate_email('skhjsgdhjghasdasdsa@gmail.com', check_mx=True) is_valid_2 = validate_email('skhjsgdhjghasdasdsa@gmail.com', verify=True) is_valid_3 = validate_email('skhjsgdhjghasdasdsa@gmail.com') is_valid_4 = validate_email('my_real_email_here@gmail.com')

print is_valid_1, is_valid_2, is_valid_3, is_valid_4

None None True True

jeechu commented 8 years ago

@victorjabur For the first 2 validations, it it returns None for not being sure. Check https://github.com/syrusakbary/validate_email/blob/master/validate_email.py#L201 I would suggest using the _validateemail.py file instead of pip install library for clarity.

For last 2, you have not added verify=True. So it only checks if the semantics of given email is correct according to RFC. Since it is correct, hence it returns True. To actually check if email exists, use verify=True.

victorjabur commented 8 years ago

I tried to use the validate_email.py and it always responding I'm not sure.

Enter email for validation: victor.jabur@lv5.com.br Validate MX record? [yN] y Try to contact server for address validation? [yN] y I'm not sure. DEBUG:validate_email:ServerError or socket.error exception raised (timed out). Enter email for validation: victorjabur@gmail.com Validate MX record? [yN] y Try to contact server for address validation? [yN] y DEBUG:validate_email:ServerError or socket.error exception raised ([Errno 101] Network is unreachable). I'm not sure.

jeechu commented 8 years ago

@victorjabur This seems like a connection issue. Maybe your port is blocked or your firewall is blocking the connection?

Enter email for validation: victor.jabur@lv5.com.br Validate MX record? [yN] y Try to contact server for address validation? [yN] y Valid!

victorjabur commented 8 years ago

@Jeechu This is the MX Record for the lv5.com.br domain that works for you.

I tried to use many internet connections and not works. What is wrong ? Could you help me ?

import smtplib smtp = smtplib.SMTP(timeout=5) smtp.connect('mx.zoho.com')

Traceback (most recent call last): File "/home/jabur/PycharmProjects/scripts/tmp/teste.txt.py", line 5, in smtp.connect('mx.zoho.com') File "/usr/lib/python2.7/smtplib.py", line 316, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket return socket.create_connection((host, port), timeout) File "/usr/lib/python2.7/socket.py", line 571, in create_connection raise err socket.timeout: timed out

victorjabur commented 8 years ago

@Jeechu Good News.

I tried to create a machine on Amazon to test this script and it works.

My gmail has been validated with success, but my victor.jabur@lv5,com.br not, as you can see follow:

Why you receive a 'Valid' and i am receiving 'Not sure' for the same email account ?

Enter email for validation: victor.jabur@lv5.com.br Validate MX record? [yN] y Try to contact server for address validation? [yN] y DEBUG:validate_email:mx.zoho.com disconected. DEBUG:validate_email:mx2.zoho.com disconected. I'm not sure.

Enter email for validation: victorjabur@gmail.com Validate MX record? [yN] y Try to contact server for address validation? [yN] y Valid!

jeechu commented 8 years ago

I tried again, and even I'm getting an error now:

Enter email for validation: victor.jabur@lv5.com.br Validate MX record? [yN] y Try to contact server for address validation? [yN] y DEBUG:validate_email:mx.zoho.com disconected. DEBUG:validate_email:ServerError or socket.error exception raised ([Errno 8] nodename nor servname provided, or not known). I'm not sure.

The server seems to be denying the connection. That can happen at times. I tried validating a large set of emails and after a point of time even yahoo, hotmail and gmail servers disconnect. This is perhaps due to their rate limiting and DoS protection.

victorjabur commented 8 years ago

I think you could improve your script applying the retry option automatically. What do you think ?

jeechu commented 8 years ago

In case of gmail, hotmail and yahoo, when the server starts denying, it will continue to do so for some time. The retry has to happen after a certain period, when the IP from which request is being made is allowed again.

What I do is set a rate limit for number of validations per minute and that usually solves the problem. But it takes more time to validate a large set.

waybarrios commented 8 years ago

Up to now, I try to do this:

Using ipython console

In [5]: print validate_email('wayner.barriosquiroga@kaust.edu,sa',verify=True) None

However, this email exists! So, what's wrong? I also installed pyDNS via pip install.

waybarrios commented 8 years ago

Correct way:

In [5]: print validate_email('wayner.barriosquiroga@kaust.edu.sa',verify=True) None

j-planet commented 8 years ago

also always returns none for me. What's up with that?

lordmayo commented 8 years ago

Works perfectly on my local machine but when I go to my production environment it won't work with verify=True or the mx option. Both of these two work on my dev environment though. I wonder what the issue is...

athifvaliyakath commented 8 years ago

Works perfectly on my local machine but when I go to my production environment it won't work and always return none

jmdahling commented 7 years ago

For those of you having connection issues, it may be that your ISP is blocking port 25 by default. Xfinity does. I created issue #61 requesting that this get updated to use port 587

taherelsheikh commented 6 years ago

I've been getting also the same problem. I've been trying to debug for a while now with no hope. Check out the logs in validate_email.py

$ python validate_email.py 
Enter email for validation: taher@hotmail.com
Validate MX record? [yN] y
Try to contact server for address validation? [yN] y
DEBUG:validate_email:ServerError or socket.error exception raised (timed out).
I'm not sure.
Enter email for validation: mona.el.sheikh@gmail.com
Validate MX record? [yN] y
Try to contact server for address validation? [yN] y
DEBUG:validate_email:ServerError or socket.error exception raised ([Errno 65] No route to host).
I'm not sure.
Enter email for validation: nour@gmail.com 
Validate MX record? [yN] y
Try to contact server for address validation? [yN] y
DEBUG:validate_email:ServerError or socket.error exception raised ([Errno 65] No route to host).
I'm not sure.

Interesting thing is that my error is either timed out OR [Errno 65] No route to host. Any ideas what to do next?

rangoski commented 5 years ago

does anyone figured out how to solve this issue ?

AVandana-1806 commented 5 years ago

I used the validate_email in the lex using Lambda to validate the email address user entered it returns None for my company email only a few time it returns. When I tried to run from the terminal it works fine. Someone help me with this issue. I can increase the timeout session for lambda and try?

njkevlani commented 5 years ago

Same issue on Google Cloud.

validate_email uses smtplib with default port, which is 25 Google Cloud Platform blocks port 25. Details here.

sourabhsinha396 commented 5 years ago

Works perfectly on my local machine but when I go to my production environment it won't work with verify=True or the mx option. Both of these two work on my dev environment though. I wonder what the issue is...

Same issue,did you get some solution

ahmedyartanveer commented 4 years ago

Same Issue with me. Working on one PC, not on the other one

Enter email for validation: ahmedyarabbasssi@gmail.com Validate MX record? [yN] y Try to contact server for address validation? [yN] y DEBUG:validate_email:ServerError or socket.error exception raised (timed out).

mr-remington commented 4 years ago

This issue seems to have been open for awhile... I just hit this in my production environment but worked fine in dev.

check_mx=True seems to open a connection to the SMTP server it receives from the MX record. In my case AWS blocks all outbound port 25 for any account. You can request this removal by filing a support ticket and this will be fixed.

I enabled it to get around the silly bug of it not parsing domains correctly, validate_email(null@gmailcom) returns True. If you're using python3 validators seems like an appropriate replacement `>>> import validators

validators.email('null@gmail.com') True validators.email('null@gmailcom') ValidationFailure(func=email, args={'value': 'null@gmailcom', 'whitelist': None})`

aveetron commented 2 years ago

verifies properly in the local, but having problem in aws. not verifying email.