From 3c3516a652f9984db62bb2d4ebdbeac96cd3f8fc Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Sat, 28 Dec 2019 11:21:08 +0530 Subject: [PATCH] fix(email): Do not encode smtp_server value (#9137) * fix: Do not encode smtp server Because it breaks in python 3 * fix: use cstr to change text_type to str Signed-off-by: Chinmay D. Pai Co-authored-by: Chinmay Pai --- frappe/email/doctype/email_domain/email_domain.py | 4 ++-- frappe/email/smtp.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frappe/email/doctype/email_domain/email_domain.py b/frappe/email/doctype/email_domain/email_domain.py index e800b839b9..c601bb1a09 100644 --- a/frappe/email/doctype/email_domain/email_domain.py +++ b/frappe/email/doctype/email_domain/email_domain.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import validate_email_address ,cint +from frappe.utils import validate_email_address ,cint, cstr import imaplib,poplib,smtplib from frappe.email.utils import get_port @@ -51,7 +51,7 @@ class EmailDomain(Document): try: if self.use_tls and not self.smtp_port: self.smtp_port = 587 - sess = smtplib.SMTP((self.smtp_server or "").encode('utf-8'), cint(self.smtp_port) or None) + sess = smtplib.SMTP(cstr(self.smtp_server or ""), cint(self.smtp_port) or None) sess.quit() except Exception: frappe.throw(_("Outgoing email account not correct")) diff --git a/frappe/email/smtp.py b/frappe/email/smtp.py index c09f3f9cdd..9eb588576d 100644 --- a/frappe/email/smtp.py +++ b/frappe/email/smtp.py @@ -8,7 +8,7 @@ import smtplib import email.utils import _socket, sys from frappe import _ -from frappe.utils import cint, parse_addr +from frappe.utils import cint, cstr, parse_addr def send(email, append_to=None, retry=1): """Deprecated: Send the message or add it to Outbox Email""" @@ -202,7 +202,7 @@ class SMTPServer: if self.use_tls and not self.port: self.port = 587 - self._sess = smtplib.SMTP((self.server or "").encode('utf-8'), + self._sess = smtplib.SMTP(cstr(self.server or ""), cint(self.port) or None) if not self._sess: