Forums

SMTP_SSL error on redhat

I got below errors when I was running below 2 lines Python code. My python version is 3.6.4. It is working fine on my local MacOS. Is there anything wrong with my redhat linux server? Can you please give some advises?

>>> from smtplib import SMTP_SSL
>>> s = SMTP_SSL('smtp.mail.yahoo.com', 465)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python3/lib/python3.6/smtplib.py", line 1030, in __init__source_address)
File "/usr/local/python3/lib/python3.6/smtplib.py", line 251, in __init__(code, msg) = self.connect(host, port)
File "/usr/local/python3/lib/python3.6/smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/usr/local/python3/lib/python3.6/smtplib.py", line 1036, in _get_socket
self.source_address)
File "/usr/local/python3/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/local/python3/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

this is on redhat?

yes, it's on redhat. I tested command telnet smtp.mail.yahoo.com 465 on redhat and got connection refused error. Is that caused by redhat server setup issue?

so it's not on pythonanywhere? can you say ping smtp.mail.yahoo.com?