From 191684f6a5d99704e58acbaa001a585e5e52e90e Mon Sep 17 00:00:00 2001 From: IOWEB TECHNOLOGIES Date: Mon, 23 Jul 2018 08:38:15 +0300 Subject: [PATCH] Add option to convert password to use ASCII instead of Unicode when needed by smtp server config (#5793) --- .../doctype/email_account/email_account.json | 35 +++++++++++++++++-- frappe/email/smtp.py | 5 ++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/frappe/email/doctype/email_account/email_account.json b/frappe/email/doctype/email_account/email_account.json index 168f1e71c6..bc6c4a5f5a 100644 --- a/frappe/email/doctype/email_account/email_account.json +++ b/frappe/email/doctype/email_account/email_account.json @@ -170,7 +170,38 @@ "set_only_once": 0, "translatable": 0, "unique": 0 - }, + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "ascii_encode_password", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Use ASCII encoding for password", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -1421,7 +1452,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-25 22:43:24.606771", + "modified": "2018-07-06 01:01:01.606771", "modified_by": "Administrator", "module": "Email", "name": "Email Account", diff --git a/frappe/email/smtp.py b/frappe/email/smtp.py index 693001b520..fa6b92fc33 100644 --- a/frappe/email/smtp.py +++ b/frappe/email/smtp.py @@ -171,7 +171,10 @@ class SMTPServer: if self.email_account: self.server = self.email_account.smtp_server self.login = getattr(self.email_account, "login_id", None) or self.email_account.email_id - self.password = self.email_account.password + if self.email_account.ascii_encode_password: + self.password = frappe.safe_encode(self.email_account.password, 'ascii') + else: + self.password = self.email_account.password self.port = self.email_account.smtp_port self.use_tls = self.email_account.use_tls self.sender = self.email_account.email_id