Stack Exchange
Trying to read emails from webmail using exchangelib
I am trying to read the emails from my Webmail account but end up getting the following error:
"name": "MalformedResponseError",
"message": "Unknown failure in response. Code: 404 headers: {'Date': 'Fri, 14 Jul 2023 10:41:23 GMT',             'Server': 'Apache', 'X-Powered-By': 'PHP/8.1.18', 'Pragma': 'no-cache', 'Expires': 'Wed, 11 Jan 1984 05:00:00 GMT', 'Cache-Control': 'no-cache, must-revalidate, max-age=0',
This is the code I tried is as below.
from exchangelib import Account,Credentials,Configuration,DELEGATE 
import time
from exchangelib import EWSDate, EWSDateTime
from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter

def connect_mail(username, password, address):
    credentials = Credentials(username=username, password=password)
    config = Configuration(server='mail.xxxx.com', credentials=credentials,auth_type='NTLM')
    account = Account(address,credentials=credentials,autodiscover=False,config=config, access_type=DELEGATE)
return account

username = "xxx@xxx.com"
password = "xxxxxxxxxx"
address = "xxx@xxx.com"
account = connect_mail(username, password, address)


The server you specified does not host the EWS API. You need to contact your Exchange server admins to get the correct address, or use autodiscover to get the server automatically.
