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
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)