2

I used to use auto discover to retrieve some emails from my inbox using exchangelib. However, last week they updated my email and auto discover is not working anymore. Now I am testing the connection with SMTPLIB using SMTP_SSL

server  = smtplib.SMTP_SSL('xxxxxxxx.com',port=25) 

but I get

ConnectionRefusedError: [WinError 10061]
c:\python37\lib\smtplib.py in __init__(self, host, port, local_hostname, keyfile, certfile, timeout, source_address, context)
   1029             self.context = context
   1030             SMTP.__init__(self, host, port, local_hostname, timeout,
-> 1031                     source_address)
   1032 
   1033         def _get_socket(self, host, port, timeout):

c:\python37\lib\smtplib.py in __init__(self, host, port, local_hostname, timeout, source_address)
    249 
    250         if host:
--> 251             (code, msg) = self.connect(host, port)
    252             if code != 220:
    253                 self.close()

c:\python37\lib\smtplib.py in connect(self, host, port, source_address)
    334         if self.debuglevel > 0:
    335             self._print_debug('connect:', (host, port))
--> 336         self.sock = self._get_socket(host, port, self.timeout)
    337         self.file = None
    338         (code, msg) = self.getreply()

c:\python37\lib\smtplib.py in _get_socket(self, host, port, timeout)
   1035                 self._print_debug('connect:', (host, port))
   1036             new_socket = socket.create_connection((host, port), timeout,
-> 1037                     self.source_address)
   1038             new_socket = self.context.wrap_socket(new_socket,
   1039                                                   server_hostname=self._host)

c:\python37\lib\socket.py in create_connection(address, timeout, source_address)
    725 
    726     if err is not None:
--> 727         raise err
    728     else:
    729         raise error("getaddrinfo returns an empty list")

c:\python37\lib\socket.py in create_connection(address, timeout, source_address)
    714             if source_address:
    715                 sock.bind(source_address)
--> 716             sock.connect(sa)
    717             # Break explicitly a reference cycle
    718             err = None

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

When I used auto discover on exchangelib I got

AutoDiscoverFailed                        Traceback (most recent call last)
<ipython-input-48-c03f25ef8bb7> in <module>
      5                     autodiscover=True,
      6                     # config=self.config,
----> 7                     access_type=DELEGATE
      8                         )

c:\python37\lib\site-packages\exchangelib\account.py in __init__(self, primary_smtp_address, fullname, access_type, autodiscover, credentials, config, locale, default_timezone)
     78                 raise AttributeError('config is ignored when autodiscover is active')
     79             self.primary_smtp_address, self.protocol = discover(email=self.primary_smtp_address,
---> 80                                                                 credentials=credentials)
     81         else:
     82             if not config:

c:\python37\lib\site-packages\exchangelib\autodiscover.py in discover(email, credentials)
    221     # We fell out of the with statement, so either cache was filled by someone else, or autodiscover redirected us to
    222     # another email address. Start over after releasing the lock.
--> 223     return discover(email=email, credentials=credentials)
    224 
    225 

c:\python37\lib\site-packages\exchangelib\autodiscover.py in discover(email, credentials)
    211             try:
    212                 # This eventually fills the cache in _autodiscover_hostname
--> 213                 return _try_autodiscover(hostname=domain, credentials=credentials, email=email)
    214             except AutoDiscoverRedirect as e:
    215                 if email.lower() == e.redirect_email.lower():

c:\python37\lib\site-packages\exchangelib\autodiscover.py in _try_autodiscover(hostname, credentials, email)
    259                     ), None)
    260                 log.info('autodiscover.%s redirected us to %s', hostname, e.server)
--> 261                 return _try_autodiscover(e.server, credentials, email)
    262             except AutoDiscoverFailed as e:
    263                 log.info('Autodiscover on autodiscover.%s (no TLS) failed (%s). Trying DNS records', hostname, e)

c:\python37\lib\site-packages\exchangelib\autodiscover.py in _try_autodiscover(hostname, credentials, email)
    277                         return _try_autodiscover(hostname=hostname_from_dns, credentials=credentials, email=email)
    278                     except AutoDiscoverFailed:
--> 279                         raise_from(AutoDiscoverFailed('All steps in the autodiscover protocol failed'), None)
    280 
    281 

c:\python37\lib\site-packages\future\utils\__init__.py in raise_from(exc, cause)
    398         myglobals['__python_future_raise_from_cause'] = cause
    399         execstr = "raise __python_future_raise_from_exc from __python_future_raise_from_cause"
--> 400         exec(execstr, myglobals, mylocals)
    401 
    402     def raise_(tp, value=None, tb=None):

c:\python37\lib\site-packages\exchangelib\autodiscover.py in <module>

AutoDiscoverFailed: All steps in the autodiscover protocol failed

I don't know how to deal with these exceptions

Santiago
  • 57
  • 1
  • 6
  • Please ass your error output as code-formatted text, not as an image! – Klaus D. Jan 22 '19 at 15:13
  • Thank you, I just made the changes – Santiago Jan 22 '19 at 15:38
  • The autodiscover protocol is notoriously flaky. You can enable debug logging in exchangelib to find the autodiscover steps that are taken, and then compare that to a test report from https://testconnectivity.microsoft.com. It could be a bad SSL certificate or something else. Feel free to open an issue in GitLab with your findings. Also, if you know which server you should be connecting to, you can disable autodiscover and connect to that server directly. – Erik Cederstrand Jan 23 '19 at 07:04

0 Answers0