diff --git a/frappe/email/smtp.py b/frappe/email/smtp.py index 2f87fc166c..e19afb56bf 100644 --- a/frappe/email/smtp.py +++ b/frappe/email/smtp.py @@ -95,7 +95,7 @@ class SMTPServer: return self._session except smtplib.SMTPAuthenticationError: - self.throw_invalid_credentials_exception() + self.throw_invalid_credentials_exception(email_account=self.email_account) except OSError as e: # Invalid mail server -- due to refusing connection @@ -128,10 +128,17 @@ class SMTPServer: self._session.quit() @classmethod - def throw_invalid_credentials_exception(cls): + def throw_invalid_credentials_exception(cls, email_account=None): original_exception = get_traceback() or "\n" + error_message = ( + _("Please check your email login credentials.") + " " + original_exception.splitlines()[-1] + ) + error_title = _("Invalid Credentials") + if email_account: + error_title = _("Invalid Credentials for Email Account: {0}").format(email_account) + frappe.throw( - _("Please check your email login credentials.") + " " + original_exception.splitlines()[-1], - title=_("Invalid Credentials"), + error_message, + title=error_title, exc=InvalidEmailCredentials, )