Sep-09-2018, 06:53 AM
While I'm trying to logon my outlook e-mail account using python inside a VDI , I'm gettin the SOCKET error
import imaplib, email, os user = '[email protected]' password = 'my_password' imap_url = 'outlook.office365.com' def auth(user,password,imap_url): con = imaplib.IMAP4_SSL(imap_url) con.login(user,password) return con con = auth(user,password,imap_url)I'm getting the below error
Error:File "C:\Program Files\Python36\lib\socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11003] getaddrinfo failed
I assume that the above error is due to the firewall . Hence I added the below code to bypass the firewall using proxyimport imaplib, email, os proxy = 'http://<username>:<password>@proxy.company.com:8080' os.environ['http_proxy'] = proxy os.environ['HTTP_PROXY'] = proxy os.environ['https_proxy'] = proxy os.environ['HTTPS_PROXY'] = proxy user = '[email protected]' password = 'my_password' imap_url = 'outlook.office365.com' def auth(user,password,imap_url): con = imaplib.IMAP4_SSL(imap_url) con.login(user,password) return con con = auth(user,password,imap_url)Now, I'm getting the below error . Can someone help me to fix this please?
Error:File "C:\Program Files\Python36\lib\socket.py", line 724, in create_connection
raise err
File "C:\Program Files\Python36\lib\socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it