Initial commit - workspace setup
- AGENTS.md, SOUL.md, USER.md, IDENTITY.md - ANAF monitor (declarații fiscale) - Kanban board + Notes UI - Email tools - Memory system
This commit is contained in:
58
tools/email_send.py
Normal file
58
tools/email_send.py
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple SMTP email sender for moltbot@romfast.ro
|
||||
Usage: python3 email_send.py "recipient@email.com" "Subject" "Body text"
|
||||
"""
|
||||
|
||||
import smtplib
|
||||
import ssl
|
||||
import sys
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
|
||||
# SMTP Configuration
|
||||
SMTP_SERVER = "mail.romfast.ro"
|
||||
SMTP_PORT = 465
|
||||
SMTP_USER = "moltbot@romfast.ro"
|
||||
SMTP_PASS = "parola281234"
|
||||
FROM_NAME = "Echo (Moltbot)"
|
||||
|
||||
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["To"] = to_email
|
||||
|
||||
# Attach body
|
||||
if html:
|
||||
msg.attach(MIMEText(body, "html", "utf-8"))
|
||||
else:
|
||||
msg.attach(MIMEText(body, "plain", "utf-8"))
|
||||
|
||||
# Connect and send
|
||||
context = ssl.create_default_context()
|
||||
with smtplib.SMTP_SSL(SMTP_SERVER, SMTP_PORT, context=context) as server:
|
||||
server.login(SMTP_USER, SMTP_PASS)
|
||||
server.sendmail(SMTP_USER, to_email, msg.as_string())
|
||||
|
||||
return {"ok": True, "to": to_email, "subject": subject}
|
||||
|
||||
except Exception as e:
|
||||
return {"ok": False, "error": str(e)}
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 4:
|
||||
print("Usage: python3 email_send.py <to> <subject> <body>")
|
||||
sys.exit(1)
|
||||
|
||||
to = sys.argv[1]
|
||||
subject = sys.argv[2]
|
||||
body = sys.argv[3]
|
||||
|
||||
result = send_email(to, subject, body)
|
||||
|
||||
import json
|
||||
print(json.dumps(result))
|
||||
Reference in New Issue
Block a user