Add option to convert password to use ASCII instead of Unicode when needed by smtp server config (#5793)

This commit is contained in:
IOWEB TECHNOLOGIES 2018-07-23 08:38:15 +03:00 committed by Rushabh Mehta
parent abd3333bae
commit 191684f6a5
2 changed files with 37 additions and 3 deletions

View file

@ -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",

View file

@ -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