import arlo

This commit is contained in:
konjacpotato
2025-11-05 21:00:19 +08:00
commit 2c8426d543
69 changed files with 789 additions and 0 deletions

0
mail/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

37
mail/mail_manager.py Normal file
View File

@ -0,0 +1,37 @@
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from log.log_manager import log
class MailManager:
def __init__(self, email: str = "1026090807@qq.com", password: str = "hqorvminmnuubebf"):
self.sender_email = email
self.server = smtplib.SMTP('smtp.qq.com', 587)
self.server.starttls() # Secure the connection
self.server.login(email, password) # Login with your email and password
def send_mail(self, subject: str, content: str, receiver_email:str = "changsongd@126.com"):
message = MIMEMultipart()
message['From'] = self.sender_email
message['To'] = receiver_email
message['Subject'] = subject
message.attach(MIMEText(content, 'plain'))
text = message.as_string()
try:
self.server.sendmail(self.sender_email, receiver_email, text)
except Exception as e:
log(f"send mail failed with error {e}. subject: {subject}")
def finish(self):
self.server.quit()
def send_mail(subject: str, content: str, receiver_email:str = None):
mail_manager = MailManager()
if receiver_email is None:
mail_manager.send_mail(subject, content)
else:
mail_manager.send_mail(subject, content, receiver_email)
mail_manager.finish()