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 <chinmaydpai@gmail.com> Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
parent
cca4ec77bf
commit
3c3516a652
2 changed files with 4 additions and 4 deletions
|
|
@ -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"))
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue