Update dashboard, memory, root +1 more (+24 ~9 -21)
This commit is contained in:
@@ -10,6 +10,8 @@ import sys
|
||||
import os
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.header import Header
|
||||
from email.utils import formataddr
|
||||
from pathlib import Path
|
||||
|
||||
# Load .env file
|
||||
@@ -27,15 +29,15 @@ SMTP_SERVER = os.environ.get('EMAIL_SERVER', 'mail.romfast.ro')
|
||||
SMTP_PORT = 465
|
||||
SMTP_USER = os.environ.get('EMAIL_USER', 'echo@romfast.ro')
|
||||
SMTP_PASS = os.environ.get('EMAIL_PASSWORD', '')
|
||||
FROM_NAME = "Echo 🌀"
|
||||
FROM_NAME = "Echo"
|
||||
|
||||
def send_email(to_email: str, subject: str, body: str, html: bool = False) -> dict:
|
||||
"""Send an email via SMTP SSL"""
|
||||
try:
|
||||
# Create message
|
||||
msg = MIMEMultipart("alternative")
|
||||
msg["Subject"] = subject
|
||||
msg["From"] = f"{FROM_NAME} <{SMTP_USER}>"
|
||||
msg["Subject"] = Header(subject, 'utf-8')
|
||||
msg["From"] = formataddr((FROM_NAME, SMTP_USER))
|
||||
msg["To"] = to_email
|
||||
|
||||
# Attach body
|
||||
@@ -57,14 +59,17 @@ def send_email(to_email: str, subject: str, body: str, html: bool = False) -> di
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 4:
|
||||
print("Usage: python3 email_send.py <to> <subject> <body>")
|
||||
print("Usage: python3 email_send.py <to> <subject> <body> [--html]")
|
||||
sys.exit(1)
|
||||
|
||||
to = sys.argv[1]
|
||||
subject = sys.argv[2]
|
||||
body = sys.argv[3]
|
||||
|
||||
result = send_email(to, subject, body)
|
||||
# Auto-detect HTML or use --html flag
|
||||
is_html = "--html" in sys.argv or body.strip().startswith("<!DOCTYPE") or body.strip().startswith("<html")
|
||||
|
||||
result = send_email(to, subject, body, html=is_html)
|
||||
|
||||
import json
|
||||
print(json.dumps(result))
|
||||
|
||||
Reference in New Issue
Block a user