use smtpilb send_message #1829 (#1830)

fixes blank messages due to encoding problem

(cherry picked from commit 1e4488ca4d)
This commit is contained in:
hawbaker 2024-01-15 03:00:56 -07:00 committed by Taha Yassine Kraiem
parent 5edd7e4786
commit 531cf7499e
2 changed files with 4 additions and 2 deletions

View file

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

View file

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