[BUG] I got the AttributeError: 'SMTP' object has no attribute 'sock' when I run the validate_email() #62
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: karolyi/py3-validate-email#62
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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):
I use colab to code
Can you please post the full traceback?
@Erica-Ko will you post the exact version of the module you use please? Also a traceback will be necessary here. I suspect you use an old, outdated version of the module.
The version info of the packages that I piped: (!python -m pip install py3-validate-email)
Requirement already satisfied: idna~=2.10 in /usr/local/lib/python3.7/dist-packages (from py3-validate-email) (2.10)
Requirement already satisfied: filelock~=3.0 in /usr/local/lib/python3.7/dist-packages (from py3-validate-email) (3.0.12)
Building wheels for collected packages: py3-validate-email
Building wheel for py3-validate-email (setup.py) ... done
Created wheel for py3-validate-email: filename=py3_validate_email-0.2.16-cp37-none-any.whl size=31762 sha256=4926d26a8236b3950688e92a6c6b2db6ae37ccb3e87fc066ccb0384ded123ec3
Stored in directory: /root/.cache/pip/wheels/74/5f/f7/7cfb53110aa234804aea8c514b98ba21e36a232361c1ed94e7
Successfully built py3-validate-email
Installing collected packages: dnspython, py3-validate-email
Successfully installed dnspython-2.1.0 py3-validate-email-0.2.16
Here is the whole traceback:
DEBUG:validate_email.mx_check:Trying mta7.am0.yahoodns.net ...
01:51:08.119471 connect: ('mta7.am0.yahoodns.net', 25)
01:51:08.119688 connect: to ('mta7.am0.yahoodns.net', 25) None
01:52:28.210582 send: 'QUIT\r\n'
timeout Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/validate_email/mx_check.py in _smtp_converse(mx_record, smtp_timeout, debug, helo_host, from_address, email_address)
116 smtp.set_debuglevel(debuglevel=2 if debug else False)
--> 117 code, message = smtp.connect(host=mx_record)
118 if code >= 400:
12 frames
/usr/lib/python3.7/smtplib.py in connect(self, host, port, source_address)
335 self._print_debug('connect:', (host, port))
--> 336 self.sock = self._get_socket(host, port, self.timeout)
337 self.file = None
/usr/lib/python3.7/smtplib.py in _get_socket(self, host, port, timeout)
306 return socket.create_connection((host, port), timeout,
--> 307 self.source_address)
308
/usr/lib/python3.7/socket.py in create_connection(address, timeout, source_address)
727 try:
--> 728 raise err
729 finally:
/usr/lib/python3.7/socket.py in create_connection(address, timeout, source_address)
715 sock.bind(source_address)
--> 716 sock.connect(sa)
717 # Break explicitly a reference cycle
timeout: timed out
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
in ()
2 logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
----> 3 print(validate_email('sms@yahoo.com', check_mx=True, debug=True))
/usr/local/lib/python3.7/dist-packages/validate_email/validate_email.py in validate_email(email_address, *args, **kwargs)
50 """
51 try:
---> 52 return validate_email_or_fail(email_address, *args, **kwargs)
53 except EmailValidationError as error:
54 message = f'Validation for {email_address!r} failed: {error}'
/usr/local/lib/python3.7/dist-packages/validate_email/validate_email.py in validate_email_or_fail(email_address, check_regex, check_mx, from_address, helo_host, smtp_timeout, dns_timeout, use_blacklist, debug, skip_smtp)
39 email_address=email_address, from_address=from_address,
40 helo_host=helo_host, smtp_timeout=smtp_timeout,
---> 41 dns_timeout=dns_timeout, skip_smtp=skip_smtp, debug=debug)
42
43
/usr/local/lib/python3.7/dist-packages/validate_email/mx_check.py in mx_check(email_address, debug, from_address, helo_host, smtp_timeout, dns_timeout, skip_smtp)
196 return _check_mx_records(
197 mx_records=mx_records, smtp_timeout=smtp_timeout, helo_host=host,
--> 198 from_address=from_address, email_address=email_address, debug=debug)
/usr/local/lib/python3.7/dist-packages/validate_email/mx_check.py in _check_mx_records(mx_records, smtp_timeout, helo_host, from_address, email_address, debug)
164 helo_host=helo_host, from_address=from_address,
165 email_address=email_address, smtp_timeout=smtp_timeout,
--> 166 debug=debug)
167 except StopIteration:
168 # Address valid, early exit
/usr/local/lib/python3.7/dist-packages/validate_email/mx_check.py in _check_one_mx(error_messages, mx_record, helo_host, from_address, email_address, smtp_timeout, debug)
140 mx_record=mx_record, smtp_timeout=smtp_timeout, debug=debug,
141 helo_host=helo_host, from_address=from_address,
--> 142 email_address=email_address)
143 except SMTPServerDisconnected:
144 return True
/usr/local/lib/python3.7/dist-packages/validate_email/mx_check.py in _smtp_converse(mx_record, smtp_timeout, debug, helo_host, from_address, email_address)
125 raise StopIteration
126 elif code >= 500:
--> 127 raise _ProtocolError('RCPT TO', code, message)
128
129
/usr/lib/python3.7/smtplib.py in exit(self, *args)
282 pass
283 finally:
--> 284 self.close()
285
286 def set_debuglevel(self, debuglevel):
/usr/lib/python3.7/smtplib.py in close(self)
975 file.close()
976 finally:
--> 977 sock = self.sock
978 self.sock = None
979 if sock:
AttributeError: 'SMTP' object has no attribute 'sock'
This will be fixed in the upcoming 1.0.0 release. Stay tuned, and thank you for your report!
Thank you for your response!
1.0.0 is out now, you should test if it works right for you, and report back.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.