Article 6NT6C What to do about this [SSL: WRONG_VERSION_NUMBER] error?

What to do about this [SSL: WRONG_VERSION_NUMBER] error?

by
Pedroski
from LinuxQuestions.org on (#6NT6C)
Having trouble sending email using Python from my laptop.

I was getting this error:

Quote:
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. For more information, go to\n5.7.8 https://support.google.com/mail/?p=BadCredentials 5b1f17b1804b1-424c82463d4sm34188795e9.10 - gsmtp')
I read I need username and password encoded base64, so I did this:

Quote:
echo -ne "me@gmail.com" | base64
and

Quote:
echo -ne "myapppassword" | base64
Good news! I don't get the BadCredentials error, but I get this [SSL: WRONG_VERSION_NUMBER] error:

Quote:
pedro@pedro-HP:~/babystuff/forAgro/python$ ./send_1_email_via_Pilar_gmail_no_attachment_V1.py
sender is me@gmail.com ...
Traceback (most recent call last):
File "/home/pedro/babystuff/forAgro/python/./send_1_email_via_Pilar_gmail_no_attachment_V1.py", line 136, in <module>
server = smtplib.SMTP_SSL(smtp_server, port, context=context)
File "/usr/lib/python3.10/smtplib.py", line 1050, in __init__
SMTP.__init__(self, host, port, local_hostname, timeout,
File "/usr/lib/python3.10/smtplib.py", line 255, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python3.10/smtplib.py", line 341, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.10/smtplib.py", line 1057, in _get_socket
new_socket = self.context.wrap_socket(new_socket,
File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "/usr/lib/python3.10/ssl.py", line 1100, in _create
self.do_handshake()
File "/usr/lib/python3.10/ssl.py", line 1371, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1007)
pedro@pedro-HP:~/babystuff/forAgro/python$
How can I know what version I need and get and use that version?

Strangely, using the QQ smtp server, username and password do not need to be base64 and my test mails are sent and received, no ssl error!
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments