Modern Authentication Methods for Office 365 and Outlook

Dear Community,
I have been trying to setup office365 email account on ERPNext. I have trying different tips and tutorials but unfortunately no success. I have used the server settings from here

When I try to register an email account. I get the following error using both App password and Account regular password. Looking forward to suggestions

Incorrect email or password. Please check your login credentials.

Traceback (most recent call last):
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 207, in check_email_server_connection
    email_server.connect()
  File "apps/frappe/frappe/email/receive.py", line 54, in connect
    return self.connect_imap()
  File "apps/frappe/frappe/email/receive.py", line 65, in connect_imap
    self.imap.login(self.settings.username, self.settings.password)
  File "/home/ubuntu/.pyenv/versions/3.8.12/lib/python3.8/imaplib.py", line 603, in login
    raise self.error(dat[-1])
imaplib.IMAP4.error: b'LOGIN failed.'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 68, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 31, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 68, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1213, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 287, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 309, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 240, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 971, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 869, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1161, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1144, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 863, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 72, in validate
    self.get_incoming_server()
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 194, in get_incoming_server
    self.check_email_server_connection(email_server, in_receive)
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 232, in check_email_server_connection
    self.throw_invalid_credentials_exception()
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 252, in throw_invalid_credentials_exception
    frappe.throw(
  File "apps/frappe/frappe/__init__.py", line 444, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
  File "apps/frappe/frappe/__init__.py", line 423, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 378, in _raise_exception
    raise raise_exception(msg)
frappe.email.doctype.email_account.email_account.InvalidEmailCredentials: Incorrect email or password. Please check your login credentials.

The same for me. Are there any tips to fix this error? Thanks!

Any Solution?

Hi @crazy_explorer @Holger_Plasser:

Check this.

Hope this helps.

1 Like