/usr/lib/imh-ultrastack-common/venv/lib/python3.13/site-packages/ngxutil
NameSizeModeActions
__pycache__/-0755rm
api.py47230644editdlrm
cache.py69380644editdlrm
cli.py107020644editdlrm
info.py149160644editdlrm
logparse.py105370644editdlrm
profile.py17580644editdlrm
report.py146180644editdlrm
sendmail.py13740644editdlrm
util.py28880644editdlrm
vts.py17100644editdlrm
__init__.py4050644editdlrm
Edit: /usr/lib/imh-ultrastack-common/venv/lib/python3.13/site-packages/ngxutil/sendmail.py (1374B)
#!/opt/imh-python/bin/python3.9 # vim: set ts=4 sw=4 expandtab syntax=python: """ ngxutil.sendmail Send email reports @author J. Hipps """ import logging import smtplib import socket from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from ngxutil import __version__, __date__ logger = logging.getLogger('ngxutil') def email_report(rcpt, sender, subject, msg_txt, msg_html=None): """ Send email report to @rcpt with @subject """ if msg_html: msg = MIMEMultipart('alternative') msg.attach(MIMEText(msg_txt, 'plain')) msg.attach(MIMEText(msg_html, 'html')) else: msg = MIMEText(msg_txt) # Add headers msg['Subject'] = subject msg['From'] = sender msg['To'] = rcpt msg['User-Agent'] = 'ngxutil/%s (%s)' % (__version__, __date__) # Send message return send_locally(msg) def send_locally(msg): """ Send message @msg via local SMTP server """ socket.setdefaulttimeout(10.0) try: smtp = smtplib.SMTP('localhost') smtp.sendmail(msg['From'], msg['To'], msg.as_string()) smtp.quit() logger.info("Sent message to %s successfully", msg['To']) except Exception as e: logger.error("Failed to send message to %s: %s", msg['To'], str(e)) return False return True