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

Closed
opened 2021-03-10 14:38:59 +01:00 by Erica-Ko · 7 comments
Erica-Ko commented 2021-03-10 14:38:59 +01:00 (Migrated from github.com)
  • [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
- [V ] I have read and understood the [FAQ](https://github.com/karolyi/py3-validate-email/blob/master/FAQ.md) **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
reinhard-mueller commented 2021-03-10 14:48:36 +01:00 (Migrated from github.com)

Can you please post the full traceback?

Can you please post the full traceback?
karolyi commented 2021-03-10 15:13:37 +01:00 (Migrated from github.com)

@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.

@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.
Erica-Ko commented 2021-03-11 09:13:33 +01:00 (Migrated from github.com)

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'

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) <ipython-input-3-fc326a2bd42a> in <module>() 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'
reinhard-mueller commented 2021-03-11 09:25:01 +01:00 (Migrated from github.com)

This will be fixed in the upcoming 1.0.0 release. Stay tuned, and thank you for your report!

This will be fixed in the upcoming 1.0.0 release. Stay tuned, and thank you for your report!
Erica-Ko commented 2021-03-11 10:20:42 +01:00 (Migrated from github.com)

This will be fixed in the upcoming 1.0.0 release. Stay tuned, and thank you for your report!

Thank you for your response!

> This will be fixed in the upcoming 1.0.0 release. Stay tuned, and thank you for your report! Thank you for your response!
karolyi commented 2021-03-14 14:33:26 +01:00 (Migrated from github.com)

1.0.0 is out now, you should test if it works right for you, and report back.

1.0.0 is out now, you should test if it works right for you, and report back.
stale[bot] commented 2021-03-28 20:30:37 +02:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: karolyi/py3-validate-email#62
No description provided.