I am trying to send an email using python 310 but am getting an error that I can't find a solution to. I should mention I am using a company proxy but this seems to work with python 3.8 so I'm not sure why it doesn't now. The code looks as such:
def send_email():
text = self.message.as_string()
with smtplib.SMTP(smtp_host, smtp_port) as server:
server.ehlo()
if server.has_extn('STARTTLS'):
server.starttls()
server.ehlo()
print(f"Sending email")
server.sendmail(sender_email, receiver_email, text)
print('Email sent')
The error is this:
File "path\mail.py", line 102, in send_email
server.starttls()
File "path\env\lib\smtplib.py", line 790, in starttls
self.sock = context.wrap_socket(self.sock,
File "path\env\lib\ssl.py", line 513, in wrap_socket
return self.sslsocket_class._create(
File "path\env\lib\ssl.py", line 1071, in _create
self.do_handshake()
File "path\env\lib\ssl.py", line 1342, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: [SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1007)
I think this is linked to OPENSSL but I can't get it to work with any changes. Does anyone know how I could fix this? Thanks
from Sending email with python 3.10 not working with error EOF occurred in violation of protocol (_ssl.c:1007)
No comments:
Post a Comment