Python Forum
Error while Logging on to outlook email account using Python inside VDI
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error while Logging on to outlook email account using Python inside VDI
#1
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 proxy

import 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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python logging RotatingFileHandler writes to random file after the first log rotation rawatg 0 397 Feb-15-2024, 11:15 AM
Last Post: rawatg
  Search Outlook Inbox for set of values cubangt 1 1,064 Jun-28-2023, 09:29 PM
Last Post: cubangt
  Save image from outlook email cubangt 1 694 Jun-07-2023, 06:52 PM
Last Post: cubangt
  Mark outlook emails as read using Python! shane88 2 6,543 Feb-24-2022, 11:19 PM
Last Post: Pedroski55
  Trying out the parsing/reading of emails from my outlook cubangt 0 6,152 Jan-12-2022, 08:59 PM
Last Post: cubangt
  Help Needed | Read Outlook email Recursively & download attachment Vinci141 1 4,075 Jan-07-2022, 07:38 PM
Last Post: cubangt
  How can I get Python Bulk Email Verification Script With API? zainalee 1 2,488 Jun-06-2021, 09:19 AM
Last Post: snippsat
  Need Outlook send email code using python srikanthpython 3 8,216 Feb-28-2021, 01:53 PM
Last Post: asyswow64
Video Python Bulk Email Verification Script With API Aj1128 0 2,621 Nov-28-2020, 11:38 AM
Last Post: Aj1128
  Sending Out Email via Python JoeDainton123 1 4,763 Aug-31-2020, 12:54 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020