I was using the following code for sending an email in Outlook:
with smtplib.SMTP_SSL("smtp.outlook.com", 465, context=context) as server:
server.login(sender_email, password)
server.sendmail(
sender_email, receiver_email, message.as_string()
)
However, I received the following error:
Traceback (most recent call last):
SMTP.__init__(self, host, port, local_hostname, timeout,
File "/usr/local/lib/python3.10/smtplib.py", line 255, in __init__
(code, msg) = self.connect(host, port)
File "/usr/local/lib/python3.10/smtplib.py", line 341, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/local/lib/python3.10/smtplib.py", line 1056, in _get_socket
new_socket = super()._get_socket(host, port, timeout)
File "/usr/local/lib/python3.10/smtplib.py", line 312, in _get_socket
return socket.create_connection((host, port), timeout,
File "/usr/local/lib/python3.10/socket.py", line 845, in create_connection
raise err
File "/usr/local/lib/python3.10/socket.py", line 833, in create_connection
sock.connect(sa)
Any help would be appreciated. Thank you. (the code works locally)