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/", line 207, in check_email_server_connection
  File "apps/frappe/frappe/email/", line 54, in connect
    return self.connect_imap()
  File "apps/frappe/frappe/email/", 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/", 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/", line 68, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/", line 31, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/", line 68, in execute_cmd
    return, **frappe.form_dict)
  File "apps/frappe/frappe/", line 1213, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/", line 21, in savedocs
  File "apps/frappe/frappe/model/", line 287, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/", line 309, in _save
    return self.insert()
  File "apps/frappe/frappe/model/", line 240, in insert
  File "apps/frappe/frappe/model/", line 971, in run_before_save_methods
  File "apps/frappe/frappe/model/", line 869, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/", line 1161, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/", line 1144, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/", line 863, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "apps/frappe/frappe/email/doctype/email_account/", line 72, in validate
  File "apps/frappe/frappe/email/doctype/email_account/", line 194, in get_incoming_server
    self.check_email_server_connection(email_server, in_receive)
  File "apps/frappe/frappe/email/doctype/email_account/", line 232, in check_email_server_connection
  File "apps/frappe/frappe/email/doctype/email_account/", line 252, in throw_invalid_credentials_exception
  File "apps/frappe/frappe/", 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/", line 423, in msgprint
  File "apps/frappe/frappe/", line 378, in _raise_exception
    raise raise_exception(msg) 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