Code Monkey home page Code Monkey logo

py3-validate-email's People

Contributors

karolyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

py3-validate-email's Issues

[BUG] I got the AttributeError: 'SMTP' object has no attribute 'sock' when I run the validate_email()

  • [V ] I have read and understood the FAQ

Describe the bug
I got the AttributeError: 'SMTP' object has no attribute 'sock' when I run the validate_email()

To Reproduce
Run the validate_email() to varify an email

Expected behavior
I expected it will return either True, False or None

Desktop (please complete the following information):

  • OS: Linux
  • Your network environment (ISP provided home connecton, or testing from an actual whitelisted server)
    I use colab to code

Support STARTTLS (port 25)

As documented in #18, my ISP blocks port 25. Similarly, Amazon also blocks port 25 by default.

When I try port smtp.gmail.com:587, it wants TLS:

09:36:19.037743 send: 'helo smtp.gmail.com\r\n'
09:36:19.089443 reply: b'250 smtp.gmail.com at your service\r\n'
09:36:19.089573 reply: retcode (250); Msg: b'smtp.gmail.com at your service'
09:36:19.089910 send: 'mail FROM:<[email protected]>\r\n'
09:36:19.137085 reply: b'530 5.7.0 Must issue a STARTTLS command first. h19sm1787816qtk.78 - gsmtp\r\n'
...

It might be useful to support TLS if it were easy, though I don't know enough to say for sure.

Python 3.7+ SMTP Value Error

Hi! We found another bug in one of our staging servers.

We use Python 3.8 and call SMTP. connect without specifying hostname in SMTP class constructor, we will get Value Error with this traceback

Traceback (most recent call last):
  File "/home/sergeyshevch/py3-validate-email/tests/test_mx_check.py", line 79, in test_gmail_false_positives
    mx_check(EmailAddress("[email protected]"), debug=True, skip_smtp=False, helo_host="smartsuite.com")
  File "/home/sergeyshevch/py3-validate-email/validate_email/mx_check.py", line 196, in mx_check
    return _check_mx_records(
  File "/home/sergeyshevch/py3-validate-email/validate_email/mx_check.py", line 162, in _check_mx_records
    found_ambigious |= _check_one_mx(
  File "/home/sergeyshevch/py3-validate-email/validate_email/mx_check.py", line 139, in _check_one_mx
    _smtp_converse(
  File "/home/sergeyshevch/py3-validate-email/validate_email/mx_check.py", line 120, in _smtp_converse
    _smtp_ehlo_tls(smtp=smtp, helo_host=helo_host)
  File "/home/sergeyshevch/py3-validate-email/validate_email/mx_check.py", line 81, in _smtp_ehlo_tls
    code, message = smtp.ehlo(name=helo_host)
  File "/home/sergeyshevch/.pyenv/versions/3.8.6/lib/python3.8/smtplib.py", line 774, in starttls
    self.sock = context.wrap_socket(self.sock,
  File "/home/sergeyshevch/.pyenv/versions/3.8.6/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/home/sergeyshevch/.pyenv/versions/3.8.6/lib/python3.8/ssl.py", line 1031, in _create
    self._sslobj = self._context._wrap_socket(
ValueError: server_hostname cannot be an empty string or start with a leading dot.

----------------------------------------------------------------------
Ran 16 tests in 2.496s

Related: ansible/ansible#44552
I will create PR today to fix it

Suggestions about the validation

Dear contributors, I have the following suggestions after I made my research about other email validation API:

  1. Detection of the catch-all property of the email server
  2. email spam traps detection
    I am not sure how to do these functions so I can't make a PR, if you know and share any resources about how to implement it, I can implement it for the project as well
    Thank you

No module named 'dns'

I get a strange error message when applying your test code:

System: Windows 10 with Python 3.9

import logging, sys 
from validate_email import validate_email

logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
print(validate_email('[email protected]', check_mx=True, debug=False))

Log:
c:/Python39/Scripts/test.py
Traceback (most recent call last):
File "c:\Python39\Scripts\test.py", line 2, in
from validate_email import validate_email
File "C:\Users\marti\AppData\Local\Programs\Python\Python39\lib\site-packages\validate_email_init_.py", line 1, in
from .validate_email import validate_email, validate_email_or_fail # NOQA
File "C:\Users\marti\AppData\Local\Programs\Python\Python39\lib\site-packages\validate_email\validate_email.py", line 8, in
from .mx_check import mx_check
File "C:\Users\marti\AppData\Local\Programs\Python\Python39\lib\site-packages\validate_email\mx_check.py", line 7, in
from dns.exception import Timeout
ModuleNotFoundError: No module named 'dns'

Failed to install on Python 3.8.6 via virtualenv

Hi,

I have seen this error been posted before. It seems to be a problem with the mac / virtualenv setup?

(chalice) ➜ aws-lambda-knockmail sudo pip3 install py3-validate-email
WARNING: The directory '/Users/sionsmith/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting py3-validate-email
Downloading py3-validate-email-0.2.10.tar.gz (12 kB)
Requirement already satisfied: dnspython~=2.0 in /Users/sionsmith/.virtualenvs/chalice/lib/python3.8/site-packages (from py3-validate-email) (2.0.0)
Requirement already satisfied: idna~=2.10 in /Users/sionsmith/.virtualenvs/chalice/lib/python3.8/site-packages (from py3-validate-email) (2.10)
Requirement already satisfied: filelock~=3.0 in /Users/sionsmith/.virtualenvs/chalice/lib/python3.8/site-packages (from py3-validate-email) (3.0.12)
Building wheels for collected packages: py3-validate-email
Building wheel for py3-validate-email (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /Users/sionsmith/.virtualenvs/chalice/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-qbrsbjm8/py3-validate-email/setup.py'"'"'; file='"'"'/private/tmp/pip-install-qbrsbjm8/py3-validate-email/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/tmp/pip-wheel-hm18gllz
cwd: /private/tmp/pip-install-qbrsbjm8/py3-validate-email/
Complete output (17 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/validate_email
copying validate_email/regex_check.py -> build/lib/validate_email
copying validate_email/mx_check.py -> build/lib/validate_email
copying validate_email/constants.py -> build/lib/validate_email
copying validate_email/init.py -> build/lib/validate_email
copying validate_email/updater.py -> build/lib/validate_email
copying validate_email/email_address.py -> build/lib/validate_email
copying validate_email/validate_email.py -> build/lib/validate_email
copying validate_email/domainlist_check.py -> build/lib/validate_email
copying validate_email/exceptions.py -> build/lib/validate_email
downloading blacklist to /private/tmp/pip-install-qbrsbjm8/py3-validate-email/build/lib/validate_email/data/blacklist.txt
error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)>

[Errno 30] Read-only file system

Hello.

Thx for your library :)

I'm using your module in the AWS Lambda. There are some limitations there, one of them is that the filesystem is R/O with exception to the /tmp dir.

When I ran:
validate_email(email_address=sender_email, check_regex=True, check_mx=True, dns_timeout=10, use_blacklist=True)

got:
[Errno 30] Read-only file system: '/opt/python/lib/python3.8/site-packages/validate_email/data'

Is there any way to specify temporary dir or maybe keep this in memory?

Regards

Please allow option to either disable "optional" blacklist or disable its output.

I use your module in a command-line utility I've written for our company, every time it starts we get the spitted out info for the blacklist check. We would really appreciate a way to disable this output.

See below:
(note that the '::>' is all you are supposed to see. Its the 'promt' part of the utility but its being covered by the output of blacklist check. My users are confused because they think its still doing something and it is not.)

(MainThread) Lock 2030992950160 acquired on C:\Users\BRANDO1.GAL\AppData\Local\Temp\tmp-py3-validate-email-1\blacklistupdater.lock
(MainThread) Lock 2030992950160 released on C:\Users\BRANDO
1.GAL\AppData\Local\Temp\tmp-py3-validate-email-1\blacklistupdater.lock
(MainThread) Starting optional update of built-in blacklist.
(Thread-1 ) Lock 2030993021976 acquired on C:\Users\BRANDO~1.GAL\AppData\Local\Temp\tmp-py3-validate-email-1\blacklistupdater.lock



||A |||l |||p |||h |||a |||C |||L |||I ||
|||||||||||||||||||||||||
|/|/|/|/|/|/|/|/|


Please enter your command. For a list of commands, use the help command.
For help with a specific command, use help commandName .

::>(Thread-1 ) Lock 2030993021976 released on C:\Users\BRANDO1.GAL\AppData\Local\Temp\tmp-py3-validate-email-1\blacklistupdater.lock
(Thread-1 ) Lock 2030992713376 acquired on C:\Users\BRANDO
1.GAL\AppData\Local\Temp\tmp-py3-validate-email-1\blacklistupdater.lock
(Thread-1 ) Lock 2030992713376 released on C:\Users\BRANDO~1.GAL\AppData\Local\Temp\tmp-py3-validate-email-1\blacklistupdater.lock

DH_KEY_TOO_SMALL for email-ids from Rediff, Yahoo and Some other Domains are getting Flagged as Invalid Emails.

Hi First of All let me thank the developers for their time on this project but I seem to have found a roadblock and wanted to know if there is any way I could check if the false negative can be weeded out of the validate_email.

Here is my code:

from validate_email import validate_email
is_valid = validate_email(email_id, check_regex=True, check_mx=True, from_address=test_email,
                          helo_host=em_domain, smtp_timeout=10, dns_timeout=10,
                          use_blacklist=True, debug=True)

Basically I am trying to validate a lot of emails and most of them are getting great responses but only in case of Yahoo or Rediff I am getting false negatives since all the email IDs are being flagged as invalid. Here is the small debug for the rediff email, I am masking the actual emails since we are on public domain for privacy related issues

Checking [email protected]
18:35:57.128154 send: 'ehlo my_ehlo_domain.com\r\n'
18:35:57.159677 reply: b'250-f4mail-234-219.rediffmail.com\r\n'
18:35:57.159782 reply: b'250-STARTTLS\r\n'
18:35:57.159809 reply: b'250-PIPELINING\r\n'
18:35:57.159827 reply: b'250 8BITMIME\r\n'
18:35:57.159853 reply: retcode (250); Msg: b'f4mail-234-219.rediffmail.com\nSTARTTLS\nPIPELINING\n8BITMIME'
18:35:57.159941 send: 'STARTTLS\r\n'
18:35:57.192523 reply: b'220 ready for tls\r\n'
18:35:57.192651 reply: retcode (220); Msg: b'ready for tls'
Validation for '[email protected]' failed: Email address undeliverable:
mx.rediffmail.rediff.akadns.net.: [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1123)
Is Valid Value = False

In case of Yahoo Emails below is the message:

Checking [email protected]
18:50:10.308048 send: 'ehlo my_domain.com\r\n'
18:50:11.181658 reply: b'250-mtaproxy301.free.mail.ne1.yahoo.com\r\n'
18:50:11.181846 reply: b'250-PIPELINING\r\n'
18:50:11.181937 reply: b'250-SIZE 41943040\r\n'
18:50:11.182018 reply: b'250-8BITMIME\r\n'
18:50:11.182101 reply: b'250 STARTTLS\r\n'
18:50:11.182231 reply: retcode (250); Msg: b'mtaproxy301.free.mail.ne1.yahoo.com\nPIPELINING\nSIZE 41943040\n8BITMIME\nSTARTTLS'
18:50:11.183393 send: 'STARTTLS\r\n'
18:50:11.463454 reply: b'220 Ready for TLS\r\n'
18:50:11.463668 reply: retcode (220); Msg: b'Ready for TLS'
18:50:14.559628 send: 'ehlo my_domain.com\r\n'
18:50:15.491714 reply: b'250-mtaproxy112.free.mail.bf1.yahoo.com\r\n'
18:50:15.491961 reply: b'250-PIPELINING\r\n'
18:50:15.492069 reply: b'250-SIZE 41943040\r\n'
18:50:15.492160 reply: b'250-8BITMIME\r\n'
18:50:15.492305 reply: b'250 STARTTLS\r\n'
18:50:15.492420 reply: retcode (250); Msg: b'mtaproxy112.free.mail.bf1.yahoo.com\nPIPELINING\nSIZE 41943040\n8BITMIME\nSTARTTLS'
18:50:15.492748 send: 'STARTTLS\r\n'
18:50:15.757847 reply: b'220 Ready for TLS\r\n'
18:50:15.758051 reply: retcode (220); Msg: b'Ready for TLS'
18:50:18.215742 send: 'ehlo my_domain.com\r\n'
18:50:18.491702 reply: b'250-mtaproxy509.free.mail.ne1.yahoo.com\r\n'
18:50:18.491875 reply: b'250-PIPELINING\r\n'
18:50:18.491951 reply: b'250-SIZE 41943040\r\n'
18:50:18.492044 reply: b'250-8BITMIME\r\n'
18:50:18.492110 reply: b'250 STARTTLS\r\n'
18:50:18.492194 reply: retcode (250); Msg: b'mtaproxy509.free.mail.ne1.yahoo.com\nPIPELINING\nSIZE 41943040\n8BITMIME\nSTARTTLS'
18:50:18.492478 send: 'STARTTLS\r\n'
18:50:18.774505 reply: b'220 Ready for TLS\r\n'
18:50:18.774765 reply: retcode (220); Msg: b'Ready for TLS'
Validation for '[email protected]' failed: Email address undeliverable:
mta5.am0.yahoodns.net.: [SSL: SSLV3_ALERT_UNEXPECTED_MESSAGE] sslv3 alert unexpected message (_ssl.c:1123)
mta6.am0.yahoodns.net.: [SSL: SSLV3_ALERT_UNEXPECTED_MESSAGE] sslv3 alert unexpected message (_ssl.c:1123)
mta7.am0.yahoodns.net.: [SSL: SSLV3_ALERT_UNEXPECTED_MESSAGE] sslv3 alert unexpected message (_ssl.c:1123)
Is Valid Value = False

[Errno 30] Read-only file system: '/opt/python/lib/python3.8/site-packages/validate_email/data'

Hi.

Sadly still with ver 0.2.1 I'm getting issue related to writting to /opt/python/lib/python3.8/site-packages/validate_email/data :/

I suppose that you didn't had time to move data file to TEMP directory yet?

[ERROR] OSError: [Errno 30] Read-only file system: '/opt/python/lib/python3.8/site-packages/validate_email/data'
Traceback (most recent call last):
  File "/var/task/serverless_sdk/__init__.py", line 130, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_EmailNotification.py", line 23, in error_handler
    raise e
  File "/var/runtime/bootstrap.py", line 131, in handle_event_request
    response = request_handler(event, lambda_context)
  File "/var/task/serverless_sdk/__init__.py", line 130, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_EmailNotification.py", line 23, in error_handler
    raise e
  File "/var/runtime/bootstrap.py", line 131, in handle_event_request
    response = request_handler(event, lambda_context)
  File "/var/task/serverless_sdk/__init__.py", line 130, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_EmailNotification.py", line 23, in error_handler
    raise e
  File "/var/task/s_EmailNotification.py", line 18, in <module>
    user_handler = serverless_sdk.get_user_handler('email_notification.handler')
  File "/var/task/serverless_sdk/__init__.py", line 54, in get_user_handler
    user_module = import_module(user_module_name)
  File "/var/lang/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/email_notification.py", line 13, in <module>
    from validate_email import validate_email
  File "/opt/python/lib/python3.8/site-packages/validate_email/__init__.py", line 1, in <module>
    from .validate_email import validate_email, validate_email_or_fail  # NOQA
  File "/opt/python/lib/python3.8/site-packages/validate_email/validate_email.py", line 4, in <module>
    from .domainlist_check import domainlist_check
  File "/opt/python/lib/python3.8/site-packages/validate_email/domainlist_check.py", line 7, in <module>
    from .updater import (
  File "/opt/python/lib/python3.8/site-packages/validate_email/updater.py", line 24, in <module>
    LIB_PATH_DEFAULT.mkdir(exist_ok=True)
  File "/var/lang/lib/python3.8/pathlib.py", line 1279, in mkdir
    self._accessor.mkdir(self, mode)

regards
Tom

Error during installation

Can anyone help me?

ERROR: Command errored out with exit status 1: command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-dwzlwitn/py3-validate-email/setup.py'"'"'; __file__='"'"'/tmp/pip-install-dwzlwitn/py3-validate-email/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-cf1xq5b4 cwd: /tmp/pip-install-dwzlwitn/py3-validate-email/ Complete output (6 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-install-dwzlwitn/py3-validate-email/setup.py", line 19 log.info(f'downloading blacklist to {BLACKLIST_FILEPATH_INSTALLED}') ^ SyntaxError: invalid syntax ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

'hidden' error message

i dont want to see error messages in the console, i only want to receive True and False, how to do this? I set debug=False

ModuleNotFoundError: No module named 'fcntl'

Hi,

I just tested the package and it keeps throwing the following error with the sample code that was provided. I am running Python 3.7 and the package version is up to date.

C:\Users\workspace\automation\venv\Scripts\python.exe C:/Users/workspace/automation/email_validation/email_val.py Traceback (most recent call last): File "C:/Users/workspace/automation/email_validation/email_val.py", line 1, in <module> from validate_email import validate_email File "C:\Users\workspace\automation\venv\lib\site-packages\validate_email\__init__.py", line 1, in <module> from .validate_email import validate_email File "C:\Users\workspace\automation\venv\lib\site-packages\validate_email\validate_email.py", line 3, in <module> from .domainlist_check import domainlist_check File "C:\Users\workspace\automation\venv\lib\site-packages\validate_email\domainlist_check.py", line 3, in <module> from .updater import BLACKLIST_FILE_PATH, BlacklistUpdater File "C:\Users\workspace\automation\venv\lib\site-packages\validate_email\updater.py", line 1, in <module> from fcntl import LOCK_EX, LOCK_UN, flock ModuleNotFoundError: No module named 'fcntl'

[enhancement] Use real email account and Port 465/587

Hi,

Most email providers reject Port 25 now.
It would be a nice enhancement to be able to test email by using secure SMTP Connection (eg : Port 465 or 587).
It's also mean to be able to use a real email account and providing user+password (so extend py3-validate-email SMTP part).
For exemple, i like to use a gmail account to test emails.

mx_check() function doesn't log exceptions

The mx_check() function inside mx_check.py catches all ValueError exceptions and it just returns False with no additional information on what the error is.

I was having some trouble validating a hotmail.co.uk email address (the address exists and is valid) and as I was tracing the error, I realised the above.

Is there a way to add logging to the mx_check() function when handling the ValueError so there is visibility on the actual errors which caused the validation to fail?

Install error on ubutnu 18.04, python 3.6.9

I got this error when trying to install it on ubutnu 18.04, python 3.6.9

Collecting py3-validate-email
Using cached py3-validate-email-0.2.8.tar.gz (10 kB)
Requirement already satisfied: dnspython~=1.16 in ./venvs/maps_scraper_env/lib/python3.6/site-packages (from py3-validate-email) (1.16.0)
Requirement already satisfied: idna~=2.8 in ./venvs/maps_scraper_env/lib/python3.6/site-packages (from py3-validate-email) (2.9)
Requirement already satisfied: filelock~=3.0 in ./venvs/maps_scraper_env/lib/python3.6/site-packages (from py3-validate-email) (3.0.12)
Building wheels for collected packages: py3-validate-email
Building wheel for py3-validate-email (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/mohamed/venvs/maps_scraper_env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zqbogb24/py3-validate-email/setup.py'"'"'; file='"'"'/tmp/pip-install-zqbogb24/py3-validate-email/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-uykv3nt3
cwd: /tmp/pip-install-zqbogb24/py3-validate-email/
Complete output (17 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/validate_email
copying validate_email/email_address.py -> build/lib/validate_email
copying validate_email/init.py -> build/lib/validate_email
copying validate_email/updater.py -> build/lib/validate_email
copying validate_email/regex_check.py -> build/lib/validate_email
copying validate_email/mx_check.py -> build/lib/validate_email
copying validate_email/exceptions.py -> build/lib/validate_email
copying validate_email/domainlist_check.py -> build/lib/validate_email
copying validate_email/constants.py -> build/lib/validate_email
copying validate_email/validate_email.py -> build/lib/validate_email
downloading blacklist to /tmp/pip-install-zqbogb24/py3-validate-email/build/lib/validate_email/data/blacklist.txt
error: HTTP Error 500: Internal Server Error

ERROR: Failed building wheel for py3-validate-email
Running setup.py clean for py3-validate-email
Failed to build py3-validate-email
Installing collected packages: py3-validate-email
Running setup.py install for py3-validate-email ... error
ERROR: Command errored out with exit status 1:
command: /home/mohamed/venvs/maps_scraper_env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zqbogb24/py3-validate-email/setup.py'"'"'; file='"'"'/tmp/pip-install-zqbogb24/py3-validate-email/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-o9pfeasr/install-record.txt --single-version-externally-managed --compile --install-headers /home/mohamed/venvs/maps_scraper_env/include/site/python3.6/py3-validate-email
cwd: /tmp/pip-install-zqbogb24/py3-validate-email/
Complete output (17 lines):
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/validate_email
copying validate_email/email_address.py -> build/lib/validate_email
copying validate_email/init.py -> build/lib/validate_email
copying validate_email/updater.py -> build/lib/validate_email
copying validate_email/regex_check.py -> build/lib/validate_email
copying validate_email/mx_check.py -> build/lib/validate_email
copying validate_email/exceptions.py -> build/lib/validate_email
copying validate_email/domainlist_check.py -> build/lib/validate_email
copying validate_email/constants.py -> build/lib/validate_email
copying validate_email/validate_email.py -> build/lib/validate_email
downloading blacklist to /tmp/pip-install-zqbogb24/py3-validate-email/build/lib/validate_email/data/blacklist.txt
error: HTTP Error 500: Internal Server Error
----------------------------------------
ERROR: Command errored out with exit status 1: /home/mohamed/venvs/maps_scraper_env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zqbogb24/py3-validate-email/setup.py'"'"'; file='"'"'/tmp/pip-install-zqbogb24/py3-validate-email/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-o9pfeasr/install-record.txt --single-version-externally-managed --compile --install-headers /home/mohamed/venvs/maps_scraper_env/include/site/python3.6/py3-validate-email Check the logs for full command output.

It's Not Checking Yahoo Email

Hi I Tried This Module But It Only Work For Gmail It's Not Working On Yahoo,Outlook,hotmail

here is the code

validation = validate_email(email_address=str(df[i]).replace(',','').replace(';',''),check_regex=True,check_mx=True, from_address='', helo_host='', smtp_timeout=30, dns_timeout=30, use_blacklist=True)

How do I debug timeouts?

Thanks for your library.

I tried it with a simple email I know exists, and it timed out as follows:

$ echo "[email protected]" | ./validate_emails.py 
Validation for '[email protected]' failed: Email address undeliverable:
ASPMX3.GOOGLEMAIL.com.: timed out
ASPMX2.GOOGLEMAIL.com.: timed out
ALT1.ASPMX.L.GOOGLE.com.: timed out
ASPMX.L.GOOGLE.com.: timed out
ALT2.ASPMX.L.GOOGLE.com.: timed out

My call is straight from the docs:

        is_valid = validate_email(
            email_address=the_email,
            check_regex=True,
            check_mx=True,
            from_address='[email protected]',
            helo_host='smtp.gmail.com',
            smtp_timeout=1,
            dns_timeout=1,
            use_blacklist=True)

How do I further debug this?

It may well be a firewall somewhere, but I can't tell where those hosts come from, or which line is timing out.

Different parts of the code use different methods to do the same thing

When looking through the code, I noticed that sometimes the same task is done in different ways:

  • mx_check uses EMAIL_EXTRACT_HOST_REGEX to split the email address into user and domain, while validate_email uses a simple rsplit('@', 1).
  • mx_check uses the idna library to resolve IDNA hostnames, while validate_email uses a simple encode('idna').

I could find no reason to not always use the simple method, which probably would make the code more understandable.

how to check if our ip is blacklisted

Hi Team

how i can check if my ip is blacklisted for checking email validity?
ii want to grep the response code like 250, 251 , etc in variable ? currently its grepping only True , false and NONE .
how i can achieve that ?

No valid exception for knowing 'Access Denied'

Exception 'AddressNotDeliverableError' is thrown both for when a server is blocked/denied and when email doesn't exist.

Gmail allows local testing if you run the following code

try:
    is_valid = validate_email_or_fail(email_address='[email protected]', check_regex=False, check_mx=True, use_blacklist=True, debug=True)
except Exception as ex:
    message = f"An exception of type {type(ex).__name__} occurred. Arguments:\n{ex.args}"
    print(message)

Inside Debug Log it will emit 'The email account that you tried to reach does not exist'

Outlook disallows local testing if you run the following code

try:
    is_valid = validate_email_or_fail(email_address='[email protected]', check_regex=False, check_mx=True, use_blacklist=True, debug=True)
except Exception as ex:
    message = f"An exception of type {type(ex).__name__} occurred. Arguments:\n{ex.args}"
    print(message)

Inside Debug Log it will emit 'Access denied, banned sending IP'

'AddressNotDeliverableError' exception cannot be both if a server got blocked and email doesn't exist.

Updater causes "OSError: [Errno 9] Bad file descriptor"

I'm using a pipenv to run my project's environment in Ubuntu with supervisor.
On start, I'm getting OSError: [Errno 9] Bad file descriptor pointing to line 89 in updater.py
with open(self._lock_file_path) as fd:
Adding a simple 'w' helped resolve the issue.
with open(self._lock_file_path, 'w') as fd:
Can we add this to the library or am I missing something?

Install error

Error Installing

Microsoft Windows [Version 10.0.18362.720]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\jandj>python -m pip install py3-validate-email
Collecting py3-validate-email
Using cached py3-validate-email-0.2.7.tar.gz (10 kB)
Requirement already satisfied: dnspython~=1.16 in c:\users\jandj\appdata\local\programs\python\python38-32\lib\site-packages (from py3-validate-email) (1.16.0)
Requirement already satisfied: idna~=2.8 in c:\users\jandj\appdata\local\programs\python\python38-32\lib\site-packages (from py3-validate-email) (2.8)
Requirement already satisfied: filelock~=3.0 in c:\users\jandj\appdata\local\programs\python\python38-32\lib\site-packages (from py3-validate-email) (3.0.12)
Installing collected packages: py3-validate-email
Running setup.py install for py3-validate-email ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\jandj\AppData\Local\Temp\pip-install-75rgqlkl\py3-validate-email\setup.py'"'"'; file='"'"'C:\Users\jandj\AppData\Local\Temp\pip-install-75rgqlkl\py3-validate-email\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\jandj\AppData\Local\Temp\pip-record-gvakcxzv\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\Include\py3-validate-email'
cwd: C:\Users\jandj\AppData\Local\Temp\pip-install-75rgqlkl\py3-validate-email
Complete output (46 lines):
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\validate_email
copying validate_email\constants.py -> build\lib\validate_email
copying validate_email\domainlist_check.py -> build\lib\validate_email
copying validate_email\email_address.py -> build\lib\validate_email
copying validate_email\exceptions.py -> build\lib\validate_email
copying validate_email\mx_check.py -> build\lib\validate_email
copying validate_email\regex_check.py -> build\lib\validate_email
copying validate_email\updater.py -> build\lib\validate_email
copying validate_email\validate_email.py -> build\lib\validate_email
copying validate_email_init_.py -> build\lib\validate_email
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\jandj\AppData\Local\Temp\pip-install-75rgqlkl\py3-validate-email\setup.py", line 57, in
setup(
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\site-packages\setuptools_init_.py", line 144, in setup
return distutils.core.setup(**attrs)
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\site-packages\setuptools\command\install.py", line 61, in run
return orig.install.run(self)
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\jandj\AppData\Local\Temp\pip-install-75rgqlkl\py3-validate-email\setup.py", line 54, in run
run_initial_updater(Path(self.build_lib))
File "C:\Users\jandj\AppData\Local\Temp\pip-install-75rgqlkl\py3-validate-email\setup.py", line 18, in run_initial_updater
from updater import BLACKLIST_FILEPATH_INSTALLED, BlacklistUpdater
ImportError: cannot import name 'BLACKLIST_FILEPATH_INSTALLED' from 'updater' (C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\lib\site-packages\updater_init_.py)
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\jandj\AppData\Local\Temp\pip-install-75rgqlkl\py3-validate-email\setup.py'"'"'; file='"'"'C:\Users\jandj\AppData\Local\Temp\pip-install-75rgqlkl\py3-validate-email\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\jandj\AppData\Local\Temp\pip-record-gvakcxzv\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\jandj\AppData\Local\Programs\Python\Python38-32\Include\py3-validate-email' Check the logs for full command output.

C:\Users\jandj>

Optional Blacklist

py3-validate-email cannot be pip installed without outbound network access since the setup.py fetches the domain blacklist file.

Cannot assign requested address

In [5]: validate_email("[email protected]", debug = True)
Validation for '[email protected]' failed: Email address undeliverable:
alt1.aspmx.l.google.com: [Errno 99] Cannot assign requested address
aspmx.l.google.com: [Errno 99] Cannot assign requested address
alt2.aspmx.l.google.com: [Errno 99] Cannot assign requested address
alt4.aspmx.l.google.com: [Errno 99] Cannot assign requested address
alt3.aspmx.l.google.com: [Errno 99] Cannot assign requested address

This package runs fine in development but in production, looks like something may be blocking it. I double-checked my firewall rules and seems for outgoing traffic. Has anyone ever seen this?

Thanks!

Everything gets rejected (25)

I'm not sure I completely get the "Everything gets rejected" part. I have a custom email address on an SMTP host (Mailjet).

I've put 'helo_host' = 'in-v3.mailjet.com' and 'from_address' = 'my_custom_email_sent_from_helo_host' as well as opened port (25) to no avail. Any ideas?

BlacklistUpdater fails to create blacklist.txt on new install

On a fresh install, where blacklist.txt is not yet present, BlacklistUpdater.process() fails because it tries to lock that non-existent file.

I see that setup.py should run BlacklistUpdater.process(), but it doesn't, at least not when installing with pip install. And if it would, it would obviously fail for the same reason anyway.

On a side note, I think that putting the updateable file inside the validate_email directory might lead to problems because on a system install, that directory might not be writeable for the process that actually runs the code.

Outdated dependencies

py3-validate-email requires specific versions of its dependencies, but for two of them newer versions would be available:

  • dnspython: 2.0 required, 2.1 available
  • idna: 2.10 required, 3.1 available
    Maybe the requirements list should be updated before the release. From a look at the version statistics, none of the updates seems to contain any change relevant for us.

Hi Karolyi

Hi Karolyi

thanks for the fix ..
now i can see exceptions are getting logged .but just want to know about the format of exception.
you can see Error code 554 is only getting displayed in the log properly. where as in 2nd case mention below , format seems to be not showing error code, can you please comment for the same.

1)Correct format
2021-02-09 03:52:10,145 ["hostmx01.logix.in: (554, b'pune2.logix.in\nIP blacklisted in http://www.senderbase.org')", "hostmx02.logix.in: (554, b'pune2.logix.in\nIP blacklisted in http://www.senderbase.org')"]

2)doubt about the below format
2021-02-09 03:52:04,534 ['mx2.zoho.in: RCPT TO failed: 5.1.1 <a.s*****@.co.in> User unknown', 'mx.zoho.in: RCPT TO failed: 5.1.1 <a.s@.co.in> User unknown', 'mx3.zoho.in: R
CPT TO failed: 5.1.1 <a.s
@*****.co.in> User unknown']

Originally posted by @manojr2k in #45 (comment)

gamil detect fail

Validation for '[email protected]' failed: Email address undeliverable:
alt3.gmail-smtp-in.l.google.com: [Errno 99] Cannot assign requested address
alt1.gmail-smtp-in.l.google.com: [Errno 99] Cannot assign requested address
alt2.gmail-smtp-in.l.google.com: [Errno 99] Cannot assign requested address
gmail-smtp-in.l.google.com: [Errno 99] Cannot assign requested address
alt4.gmail-smtp-in.l.google.com: [Errno 99] Cannot assign requested address

Install py3-validate-email issue

Hello, I have an issue when I run "pip install py3-validate-email"

> pip install py3-validate-email
Collecting py3-validate-email
  Using cached py3-validate-email-0.2.8.tar.gz (10 kB)
Requirement already satisfied: dnspython~=1.16 in /Users/tonyricher/.local/share/virtualenvs/python-IceqmoFh/lib/python
3.8/site-packages (from py3-validate-email) (1.16.0)
Requirement already satisfied: idna~=2.8 in /Users/tonyricher/.local/share/virtualenvs/python-IceqmoFh/lib/python3.8/si
te-packages (from py3-validate-email) (2.9)
Requirement already satisfied: filelock~=3.0 in /Users/tonyricher/.local/share/virtualenvs/python-IceqmoFh/lib/python3.
8/site-packages (from py3-validate-email) (3.0.12)
Building wheels for collected packages: py3-validate-email
  Building wheel for py3-validate-email (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/tonyricher/.local/share/virtualenvs/python-IceqmoFh/bin/python -u -c 'import sys, setuptools, tokeni
ze; sys.argv[0] = '"'"'/private/var/folders/bf/8d8nnwtd2p5141vk9dt8tb8c0000gn/T/pip-install-lqtgfwbl/py3-validate-email
/setup.py'"'"'; __file__='"'"'/private/var/folders/bf/8d8nnwtd2p5141vk9dt8tb8c0000gn/T/pip-install-lqtgfwbl/py3-validat
e-email/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n
'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/bf/8d8nnwtd2p5141vk
9dt8tb8c0000gn/T/pip-wheel-x0js53ir
       cwd: /private/var/folders/bf/8d8nnwtd2p5141vk9dt8tb8c0000gn/T/pip-install-lqtgfwbl/py3-validate-email/
  Complete output (17 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  creating build/lib/validate_email
  copying validate_email/regex_check.py -> build/lib/validate_email
  copying validate_email/mx_check.py -> build/lib/validate_email
  copying validate_email/constants.py -> build/lib/validate_email
  copying validate_email/__init__.py -> build/lib/validate_email
  copying validate_email/updater.py -> build/lib/validate_email
  copying validate_email/email_address.py -> build/lib/validate_email
  copying validate_email/validate_email.py -> build/lib/validate_email
  copying validate_email/domainlist_check.py -> build/lib/validate_email
  copying validate_email/exceptions.py -> build/lib/validate_email
  downloading blacklist to /private/var/folders/bf/8d8nnwtd2p5141vk9dt8tb8c0000gn/T/pip-install-lqtgfwbl/py3-validate-email/build/lib/validate_email/data/blacklist.txt
  error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>
  ----------------------------------------
  ERROR: Failed building wheel for py3-validate-email
  Running setup.py clean for py3-validate-email
Failed to build py3-validate-email
Installing collected packages: py3-validate-email
    Running setup.py install for py3-validate-email ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/tonyricher/.local/share/virtualenvs/python-IceqmoFh/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/bf/8d8nnwtd2p5141vk9dt8tb8c0000gn/T/pip-install-lqtgfwbl/py3-validate-email/setup.py'"'"'; __file__='"'"'/private/var/folders/bf/8d8nnwtd2p5141vk9dt8tb8c0000gn/T/pip-install-lqtgfwbl/py3-validate-email/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/bf/8d8nnwtd2p5141vk9dt8tb8c0000gn/T/pip-record-kutwh01b/install-record.txt --single-version-externally-managed --compile --install-headers /Users/tonyricher/.local/share/virtualenvs/python-IceqmoFh/include/site/python3.8/py3-validate-email
         cwd: /private/var/folders/bf/8d8nnwtd2p5141vk9dt8tb8c0000gn/T/pip-install-lqtgfwbl/py3-validate-email/
    Complete output (17 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/validate_email
    copying validate_email/regex_check.py -> build/lib/validate_email
    copying validate_email/mx_check.py -> build/lib/validate_email
    copying validate_email/constants.py -> build/lib/validate_email
    copying validate_email/__init__.py -> build/lib/validate_email
    copying validate_email/updater.py -> build/lib/validate_email

I don't know why .. Could you help me ?

MX check on private domain fails

Hi,
I have an issue where running validate_email on my private email address does not work. I am able to successfully verify public domain addresses (i.e. @gmail.com etc)

So, if I run validate_email on any addresses @stumbra.co.uk (my personal domain), it can find the MX records, but it appears that its telnet attempts fail.

Input:
>>> print(validate_email('[email protected]', check_mx=True, debug=True))

Result:
DEBUG:validate_email.mx_check:Trying hermes.hosts.co.uk ...
DEBUG:validate_email.mx_check:Trying athena.hosts.co.uk ...
None

The issue appears to be that it cannot connect to them over telnet, and excluding domains where telnet fails with check_mx flag doesn't make sense. While I could do a check where if validate_email returns None to run it without the check_mx flag, I feel like that could lead to false positives.

Any advice/suggestions?

'hotmail' server TimeOut

When I check "hotmail" emails ([email protected], [email protected], ...), I always get a 'TimeOut' socket error.

    import logging, sys; 
    from validate_email import validate_email
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
    print(validate_email('[email protected]', check_regex=True, check_mx=True, debug=True))

Got :

WARNING:validate_email.validate_email:Validation for '[email protected]' failed: Email address undeliverable:
hotmail-com.olc.protection.outlook.com.: timed out

Every request is timing out.

Every email I try and verify times out and then fails. Can't figure out what I'm doing wrong

Here is the output of the debugging:

 (venv) Hs-MacBook-Pro:pythonProject4 hdanforthirwin$ python -c 'import logging, sys; logging.basicConfig(stream=sys.stderr, level=logging.DEBUG); from validate_email import validate_email; print(validate_email("[email protected]", check_mx=True, debug=True))'
DEBUG:filelock:Attempting to acquire lock 4523126688 on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
INFO:filelock:Lock 4523126688 acquired on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
DEBUG:validate_email.domainlist_check:(Re)loading blacklist from /Users/hdanforthirwin/PycharmProjects/pythonProject4/venv/lib/python3.9/site-packages/validate_email/data/blacklist.txt
DEBUG:filelock:Attempting to release lock 4523126688 on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
INFO:filelock:Lock 4523126688 released on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
DEBUG:validate_email.updater:Starting optional update of built-in blacklist.
DEBUG:filelock:Attempting to acquire lock 4531404608 on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
INFO:filelock:Lock 4531404608 acquired on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
DEBUG:validate_email.updater:Not updating because file is fresh enough.
DEBUG:filelock:Attempting to release lock 4531404608 on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
INFO:filelock:Lock 4531404608 released on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
DEBUG:filelock:Attempting to acquire lock 4531470592 on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
INFO:filelock:Lock 4531470592 acquired on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
DEBUG:validate_email.domainlist_check:(Re)loading blacklist from /Users/hdanforthirwin/PycharmProjects/pythonProject4/venv/lib/python3.9/site-packages/validate_email/data/blacklist.txt
DEBUG:filelock:Attempting to release lock 4531470592 on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
INFO:filelock:Lock 4531470592 released on /var/folders/3j/cwnxk5xx3_g3lq398pxd041m0000gn/T/tmp-py3-validate-email-501/blacklistupdater.lock
DEBUG:validate_email.mx_check:Trying ALT1.ASPMX.L.GOOGLE.com ...
DEBUG:validate_email.mx_check:Trying ALT2.ASPMX.L.GOOGLE.com ...
DEBUG:validate_email.mx_check:Trying ASPMX2.GOOGLEMAIL.com ...
DEBUG:validate_email.mx_check:Trying ASPMX3.GOOGLEMAIL.com ...
DEBUG:validate_email.mx_check:Trying ASPMX.L.GOOGLE.com ...
WARNING:validate_email.validate_email:Validation for '[email protected]' failed: Email address undeliverable:
ALT1.ASPMX.L.GOOGLE.com: timed out
ALT2.ASPMX.L.GOOGLE.com: timed out
ASPMX2.GOOGLEMAIL.com: timed out
ASPMX3.GOOGLEMAIL.com: timed out
ASPMX.L.GOOGLE.com: timed out
False
(venv) Hs-MacBook-Pro:pythonProject4 hdanforthirwin$ 

Other things of note:

I had a lot of trouble getting dnspython installed. Maybe its running, but not actually installed properly? It seems to work when I do a simple socket.gethostbyname_ex() though.

image

Hunter.io has no problem verifying the email address:

image

(On a 2017 MacBook Pro with Big Sur 11.1. PyCharm and Python 3.9. Tried it with both a VPN and no VPN)

Limited Emails

Hi!
We found some issues with organization emails located on google suite.

Some accounts in these organizations cannot send or receive emails. So if we try to send a registration email on it, we get a bounce on AWS SES.

How do you think, is there any way to check these email addresses?

There are parts of some AWS bounce notifications:

[{"emailAddress":"MASKEDUSEREMAIL","action":"failed","status":"5.7.1","diagnosticCode":"smtp; 550-5.7.1 This message has been rejected as this student is not able to send or\n550 5.7.1 receive external mail. - gcdp g5si1130787uad.263 - gsmtp"}],"timestamp":"2021-02-18T16:49:33.000Z","remoteMtaIp":"173.194.209.27",

smtp; 550-5.7.1 Sorry, sending email outside of the CBE Google Apps domain,\n550-5.7.1 @educbe.ca, is not permitted for staff accounts, exceptions are

There is debug log of validate_email call (was done locally):

21:07:36.120543 connect: ('alt2.aspmx.l.google.com', 25)
21:07:36.120646 connect: to ('alt2.aspmx.l.google.com', 25) None
21:07:36.608010 reply: b'220 mx.google.com ESMTP m22si5637782pgu.215 - gsmtp\r\n'
21:07:36.608090 reply: retcode (220); Msg: b'mx.google.com ESMTP m22si5637782pgu.215 - gsmtp'
21:07:36.608132 connect: b'mx.google.com ESMTP m22si5637782pgu.215 - gsmtp'
21:07:36.608164 send: 'ehlo my.host.name\r\n'
21:07:36.864789 reply: b'250-mx.google.com at your service, [85.26.165.2]\r\n'
21:07:36.864890 reply: b'250-SIZE 157286400\r\n'
21:07:36.864920 reply: b'250-8BITMIME\r\n'
21:07:36.864947 reply: b'250-STARTTLS\r\n'
21:07:36.864972 reply: b'250-ENHANCEDSTATUSCODES\r\n'
21:07:36.864997 reply: b'250-PIPELINING\r\n'
21:07:36.865021 reply: b'250-CHUNKING\r\n'
21:07:36.865045 reply: b'250 SMTPUTF8\r\n'
21:07:36.865077 reply: retcode (250); Msg: b'mx.google.com at your service, [85.26.165.2]\nSIZE 157286400\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8'
21:07:36.865794 send: 'STARTTLS\r\n'
21:07:37.091898 reply: b'220 2.0.0 Ready to start TLS\r\n'
21:07:37.092001 reply: retcode (220); Msg: b'2.0.0 Ready to start TLS'
21:07:37.353562 send: 'ehlo my.host.name\r\n'
21:07:37.844762 reply: b'250-mx.google.com at your service, [85.26.165.2]\r\n'
21:07:37.844877 reply: b'250-SIZE 157286400\r\n'
21:07:37.844919 reply: b'250-8BITMIME\r\n'
21:07:37.844954 reply: b'250-ENHANCEDSTATUSCODES\r\n'
21:07:37.844987 reply: b'250-PIPELINING\r\n'
21:07:37.845018 reply: b'250-CHUNKING\r\n'
21:07:37.845054 reply: b'250 SMTPUTF8\r\n'
21:07:37.845114 reply: retcode (250); Msg: b'mx.google.com at your service, [85.26.165.2]\nSIZE 157286400\n8BITMIME\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8'
21:07:37.845492 send: 'mail FROM:<[email protected]>\r\n'
21:07:38.090705 reply: b'250 2.1.0 OK m22si5637782pgu.215 - gsmtp\r\n'
21:07:38.090835 reply: retcode (250); Msg: b'2.1.0 OK m22si5637782pgu.215 - gsmtp'
21:07:38.091075 send: 'rcpt TO:<MASKEDUSEREMAIL>\r\n'
21:07:39.053906 reply: b'250 2.1.5 OK m22si5637782pgu.215 - gsmtp\r\n'
21:07:39.054053 reply: retcode (250); Msg: b'2.1.5 OK m22si5637782pgu.215 - gsmtp'
21:07:39.054121 send: 'QUIT\r\n'
21:07:39.282447 reply: b'221 2.0.0 closing connection m22si5637782pgu.215 - gsmtp\r\n'
21:07:39.282578 reply: retcode (221); Msg: b'2.0.0 closing connection m22si5637782pgu.215 - gsmtp'

Script i was used for testing

from validate_email.validate_email import validate_email
import argparse

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("email", metavar="email")

    args = parser.parse_args()

    is_valid = validate_email(
        email_address=args.email,
        check_regex=True,
        check_mx=True,
        from_address="[email protected]",
        helo_host="my.host.name",
        smtp_timeout=10,
        dns_timeout=10,
        use_blacklist=True,
        debug=True,
    )

    print(f'RESULT: {"Valid" if is_valid else "InValid"}')

Cannot verify own email

Replaced the previous validate-email package with py3-validate-email.
However, validate_email() returns None for my mail Id.

Validation from Secured EC2

Hi, quick question regarding validation from my HTTPS EC2. I'll start by saying all works perfectly locally, so I'm wondering if you've had this issue before or have any tips when using on AWS.

I have opened port 25 on my ec2's security group for all inbound requests (all outbound requests open as well). Additionally, I can send emails using Gmail's smtp server successfully from my EC2. In the mean time I have contacted AWS to ask if there are any restrictions in place that they can lift. Below is my error:

>>> validate_email(email_address='[email protected]', check_mx=True, from_address='[email protected]', helo_host='smtp.gmail.com', smtp_timeout=10, dns_timeout=10, use_blacklist=True, debug=True)
13:45:37.654641 connect: ('alt3.gmail-smtp-in.l.google.com.', 25)
13:45:37.654772 connect: to ('alt3.gmail-smtp-in.l.google.com.', 25) None
13:45:47.665600 connect: ('alt2.gmail-smtp-in.l.google.com.', 25)
13:45:47.665773 connect: to ('alt2.gmail-smtp-in.l.google.com.', 25) None
13:45:57.678526 connect: ('alt1.gmail-smtp-in.l.google.com.', 25)
13:45:57.678581 connect: to ('alt1.gmail-smtp-in.l.google.com.', 25) None
13:46:07.691279 connect: ('gmail-smtp-in.l.google.com.', 25)
13:46:07.691333 connect: to ('gmail-smtp-in.l.google.com.', 25) None
13:46:17.704288 connect: ('alt4.gmail-smtp-in.l.google.com.', 25)
13:46:17.704344 connect: to ('alt4.gmail-smtp-in.l.google.com.', 25) None
Validation for '[email protected]' failed: Email address undeliverable:
alt3.gmail-smtp-in.l.google.com.: [Errno 101] Network is unreachable
alt2.gmail-smtp-in.l.google.com.: [Errno 101] Network is unreachable
alt1.gmail-smtp-in.l.google.com.: [Errno 101] Network is unreachable
gmail-smtp-in.l.google.com.: [Errno 101] Network is unreachable
alt4.gmail-smtp-in.l.google.com.: [Errno 101] Network is unreachable
False

Any help is greatly appreciated (note: I have also read through the other issue on the repo #19).

Thanks!

support black list in aws lambda

for use in aws lambda, where data is not persistent

  1. allow disable of update completely
  2. allow override of path using lambda function for efs
  3. or support storing of update on s3

Cannot verify my own address

Thanks for the great work putting this together. I am having issues making it work, I did a first trial with my own email address and it returns that it cannot be validated. Can you please advise?

from validate_email import validate_email
is_valid = validate_email(email_address=my_gmail_address, check_regex=True, check_mx=True)

Validation for my_email_address failed: Email address undeliverable:
alt2.gmail-smtp-in.l.google.com.: [Errno 99] Cannot assign requested address
alt3.gmail-smtp-in.l.google.com.: [Errno 99] Cannot assign requested address
alt4.gmail-smtp-in.l.google.com.: [Errno 99] Cannot assign requested address
gmail-smtp-in.l.google.com.: [Errno 99] Cannot assign requested address
alt1.gmail-smtp-in.l.google.com.: [Errno 99] Cannot assign requested address

Idea how to clean up the parameter list of validate_email[_or_fail]

With the growing number of checks that can be switched on and off, the parameter list has become somewhat long and cluttered, switches are named use_*, check_*, or skip_*, and also some have to be set to True to enable a test, some to True to disable the test.

I had the idea of replacing all these parameters with a single one:

First, we define a constant for each of the possible checks:

CHECK_FORMAT = 1
CHECK_BLACKLIST = 2
CHECK_MX = 3
CHECK_SMTP = 4
CHECK_SMTP_COMMUNICATION = 5
CHECK_SMTP_TEMPORARY = 6

and we define the default set of checks as a Python set:

CHECK_DEFAULT = {CHECK_FORMAT, CHECK_BLACKLIST, CHECK_MX, CHECK_SMTP}

Then, we can change validate_email_or_fail to accept the parameter checks: Set = CHECK_DEFAULT.

Downside: this would either break compatibility with previous versions, or we'd have to accept both options for a while, adding a deprecation warning when the old parameters are used.

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.