简体   繁体   English

如何修复错误 ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] 版本号错误?

[英]How to fix the error ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number?

I am trying to send email using python but i am getting error while sending the email, i have also tried with both the commands (with python2 and python3) while executing the code我正在尝试使用 python 发送 email 但在发送 email 时出现错误,我在执行代码时也尝试了这两个命令(使用 python2 和 python3)

import smtplib,ssl

content= "prince kumar"

mail = smtplib.SMTP_SSL('gmail-smtp-in.l.google.com', 25)
#mail.ehlo()

#mail.starttls()

mail.login('kmrprncanu@gmail.com','83412adsf234sad')

mail.sendmail('kmrprncanu@gmail.com', 'kmrprnc44@gmail.com',content)

mail.close()

Error:错误:

  root@localhost:~# python smtp.py 
   Traceback (most recent call last):
 File "smtp.py", line 6, in <module>
mail = smtplib.SMTP_SSL('smtp.gmail.com', 587)
File "/usr/lib/python2.7/smtplib.py", line 802, in __init__
 SMTP.__init__(self, host, port, local_hostname, timeout)
File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 317, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python2.7/smtplib.py", line 808, in _get_socket
new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile)
File "/usr/lib/python2.7/ssl.py", line 949, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 617, in __init__
  self.do_handshake()
 File "/usr/lib/python2.7/ssl.py", line 846, in do_handshake
self._sslobj.do_handshake()
 ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:726)

It looks like the error is stemming from the wrong use of a port number.看起来错误是由错误使用port号引起的。

You need to change the port from 25 to 465 or 587(ideally) to use SMTP with SSL;您需要将端口从 25 更改为 465 或 587(理想情况下)以使用 SMTP 和 SSL; port 25 is often used for non-encrypted email.端口 25 通常用于未加密的 email。 So apply the change to this line and it should solve your problem.因此,将更改应用于此行,它应该可以解决您的问题。

mail = smtplib.SMTP_SSL('gmail-smtp-in.l.google.com', 587)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复 ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] 错误的版本号 (_ssl.c:1056)? - How to fix ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)? django2.1发送电子邮件失败:ssl.SSLError:[SSL:WRONG_VERSION_NUMBER]版本号错误(_ssl.c:833) - django2.1 send email fail:ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:833) python 请求:(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] 错误的版本号 (_ssl.c:1123)')) - python requests: (SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)')) SSL:PYTHON 请求上的 WRONG_VERSION_NUMBER - SSL: WRONG_VERSION_NUMBER ON PYTHON REQUEST jupyter SSL:WRONG_VERSION_NUMBER - jupyter SSL: WRONG_VERSION_NUMBER python elasticsearch elasticsearch.exceptions.SSLError: ConnectionError([SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)) - python elasticsearch elasticsearch.exceptions.SSLError: ConnectionError([SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)) Python-Django [SSL:WRONG_VERSION_NUMBER]错误 - Python-Django [SSL: WRONG_VERSION_NUMBER] Error elastic_transport.TlsError:TLS错误导致:TlsError(TLS错误导致:SSLError([SSL:WRONG_VERSION_NUMBER]版本号错误(_ssl.c:852))) - elastic_transport.TlsError: TLS error caused by:TlsError(TLS error caused by: SSLError([SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:852))) Flask-Mail [SSL: WRONG_VERSION_NUMBER] 错误的版本号 (_ssl.c:1123) - Flask-Mail [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123) python 3 smtplib 异常:“SSL:WRONG_VERSION_NUMBER”登录到 Outlook - python 3 smtplib exception: 'SSL: WRONG_VERSION_NUMBER' logging in to outlook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM