fixes blank messages due to encoding problem
This commit is contained in:
parent
557e60b1b7
commit
1e4488ca4d
2 changed files with 4 additions and 2 deletions
|
|
@ -69,7 +69,7 @@ def send_html(BODY_HTML, SUBJECT, recipient, bcc=None):
|
|||
r += [bcc]
|
||||
try:
|
||||
logging.info(f"Email sending to: {r}")
|
||||
s.sendmail(msg['FROM'], r, msg.as_string().encode('ascii'))
|
||||
s.send_message(msg)
|
||||
except Exception as e:
|
||||
logging.error("!!! Email error!")
|
||||
logging.error(e)
|
||||
|
|
@ -84,7 +84,7 @@ def send_text(recipients, text, subject):
|
|||
body = MIMEText(text)
|
||||
msg.attach(body)
|
||||
try:
|
||||
s.sendmail(msg['FROM'], recipients, msg.as_string().encode('ascii'))
|
||||
s.send_message(msg)
|
||||
except Exception as e:
|
||||
logging.error("!! Text-email failed: " + subject),
|
||||
logging.error(e)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ class EmptySMTP:
|
|||
def sendmail(self, from_addr, to_addrs, msg, mail_options=(), rcpt_options=()):
|
||||
logging.error("!! CANNOT SEND EMAIL, NO VALID SMTP CONFIGURATION FOUND")
|
||||
|
||||
def send_message(self, msg):
|
||||
self.sendmail( msg["FROM"], msg["TO"], msg.as_string() )
|
||||
|
||||
class SMTPClient:
|
||||
server = None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue