0

Currently I am using RHEL8 server which has not internet connection to it. In that server I have implemented a Jupyter notebook and I have used following code to connect with IMAP.

  import imaplib

    imap = imaplib.IMAP4_SSL('imap-mail.outlook.com',995)
    # authenticate
    imap.login(username, password)
    imap.select()

I am having following error.

OSError: [Errno 97] Address family not supported by protocol

Can someone explain whether this error is occurring due to unavailability of internet or any other reason? How should I create a proxy and pass this through it?

Here I have implemented a proxy and checked the connectivity as follows. Now I need to connect this to IMAP. But I couldn't identify the correct method to do that.

http_proxy  = "http://10.48.250.90:3128"
https_proxy = "https://10.48.250.90:3128"
ftp_proxy   = "ftp://10.48.250.90:3128"

proxyDict = { 
              "http"  : http_proxy, 
              "https" : https_proxy, 
              "ftp"   : ftp_proxy
            }

# setting up the URL and checking the conection by printing the status
url = "https://imap-mail.outlook.com"
#url = 'https://www.google.lk'
page = requests.get(url, proxies=proxyDict)
print(page.status_code)
print(page.url)
#print(page.text)
Shehan
  • 417
  • 2
  • 11
  • "*How should I create a proxy and pass this through it?*" Creation of a proxy is a large, complex topic informed by lots of requirements. It's *much* too broad to be asking about here - a well-formed search on your preferred search engine should lead you to numerous tutorials on the topic. However it's not a good fit for Stack Overflow's Q&A format. – esqew Nov 29 '21 at 17:10
  • Can you elaborate on how exactly you expect to make a connection to an Internet IMAP server when your server explicitly does not have a connection to the Internet...? – esqew Nov 29 '21 at 17:10
  • @esqew I have updated the question.Can you check and suggest? – Shehan Nov 29 '21 at 17:16
  • @Shehan How does the second script relate to the first? Where is your reference to `imaplib`? Why are you trying to use `https` to contact an `IMAP` server? If you struggle with these concepts, you may want to brush up on how these protocols are different from one another before continuing. It's also clearly a duplicate of https://stackoverflow.com/questions/3386724/how-can-i-fetch-emails-via-pop-or-imap-through-a-proxy – esqew Nov 29 '21 at 17:19

0 Answers0