1

I'm trying to validate emails using validate_email 1.3 : Python Package Index, like this:

from validate_email import validate_email
is_valid = validate_email('[email protected]',check_mx=True)

How can I speed this up? My for loop isn't very effective with amount of emails I need to verify...

3
  • I think speeding this up is rather impossible since check_mx checks every SMTP-server by trying to establish a connection to it wich takes some time. However, since this is a so called I/O-bound process you can try to use different threads in parallel. Commented Feb 17, 2016 at 19:16
  • 1
    Do you just want to validate that the string looks like a proper email address, or do you need to verify that the email account actually exists? Commented Feb 17, 2016 at 19:21
  • I need to verify MX record as well, I'm thinking of "multithreading" ... Commented Feb 17, 2016 at 19:30

1 Answer 1

3

Only use check_mx=True the first time you encounter a domain. After that, just use a regex to validate the address.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm not sure what you mean.
If I to use verify=False in addition to check_mx=True, your solution wouldn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.