ERPNext.com Frappe Cloud Support Partners Foundation

Office365 mail IMAP works fine, but SMTP for same account fails authentication

I have a standard domain set-up which should send/receive mail via Office365 mail servers.

It works perfectly well for receiving e-mail, and in the “Domain” document, it accepts the sending (SMTP) settings and Saves without problem.

Once I’m setting up in the Email Account document (screenshots posted below), the SMTP doesn’t verify, and if I disable it to save the detail, it does not send the actual mail, and produces the error posted below, which seems to me like Authentication is failing due to the physical user/password - but how can this be possible when RECEIVE works with the same authentication detail?

To prove to myself that the server does actually work - I set up the same settings in Thunderbird, where it both received and sent with the same authentication, and to be transparent, here is the mail-setting in Thunderbird:

Please let me know what I can check/double-check/change to try and solve this issue.

Error Detail:
Traceback (most recent call last):
File “/home/frappie/erp/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 260, in save
return self._save(*args, **kwargs)
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 296, in save
self.run_before_save_methods()
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 876, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 772, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 1048, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 1031, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 766, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappie/erp/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 73, in validate
self.check_smtp()
File “/home/frappie/erp/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 140, in check_smtp
server.sess
File “/home/frappie/erp/apps/frappe/frappe/email/smtp.py”, line 232, in sess
raise
(frappe.ValidationError, e, traceback)
File “/home/frappie/erp/env/lib/python3.6/site-packages/six.py”, line 696, in reraise
raise value
File “/home/frappie/erp/apps/frappe/frappe/email/smtp.py”, line 219, in sess
ret = self._sess.login(str(self.login or “”), str(self.password or “”))
File “/usr/lib64/python3.6/smtplib.py”, line 730, in login
raise last_exception
File “/usr/lib64/python3.6/smtplib.py”, line 721, in login
initial_response_ok=initial_response_ok)
File “/usr/lib64/python3.6/smtplib.py”, line 642, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b’Incorrect authentication data’)

Traceback (most recent call last):
File “/home/frappie/erp/apps/frappe/frappe/app.py”, line 61, in application
response = frappe.handler.handle()
File “/home/frappie/erp/apps/frappe/frappe/handler.py”, line 21, in handle
data = execute_cmd(cmd)
File “/home/frappie/erp/apps/frappe/frappe/handler.py”, line 56, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappie/erp/apps/frappe/frappe/init.py”, line 1036, in call
return fn(*args, **newargs)
File “/home/frappie/erp/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 260, in save
return self._save(*args, **kwargs)
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 296, in save
self.run_before_save_methods()
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 876, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 772, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 1048, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 1031, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappie/erp/apps/frappe/frappe/model/document.py”, line 766, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappie/erp/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 73, in validate
self.check_smtp()
File “/home/frappie/erp/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 140, in check_smtp
server.sess
File “/home/frappie/erp/apps/frappe/frappe/email/smtp.py”, line 232, in sess
raise
(frappe.ValidationError, e, traceback)
File “/home/frappie/erp/env/lib/python3.6/site-packages/six.py”, line 696, in reraise
raise value
File “/home/frappie/erp/apps/frappe/frappe/email/smtp.py”, line 219, in sess
ret = self._sess.login(str(self.login or “”), str(self.password or “”))
File “/usr/lib64/python3.6/smtplib.py”, line 730, in login
raise last_exception
File “/usr/lib64/python3.6/smtplib.py”, line 721, in login
initial_response_ok=initial_response_ok)
File “/usr/lib64/python3.6/smtplib.py”, line 642, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b’Incorrect authentication data’)

Domain document:

Mail document:

Hi!

we have setup an IMAP account for a customer. We booked a simple IMAP Account on their Office 365:

Here are the settings:

I have found, that you sometimes need to recreate the email account completely after changing the domain. If you just edited the original notifications account please concider creating it from scratch.

Best
Wolfram