Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 89b5a69325 | |||
| 23810cf180 | |||
| 16400b0359 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"thresholds": {
|
||||
"cpu": 75,
|
||||
"memory": 80,
|
||||
"disk": 85,
|
||||
"interval": 60
|
||||
"interval": 60,
|
||||
"memory": 80,
|
||||
"cpu_temp": 70
|
||||
},
|
||||
"web_settings": {
|
||||
"external_ip": "121.40.164.32",
|
||||
|
||||
30388
logs/app.log
30388
logs/app.log
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,9 @@ def register_email_routes(app):
|
||||
def api_email_send():
|
||||
"""发送邮件通知"""
|
||||
data = request.get_json()
|
||||
log_message(f"📨 收到邮件请求: {data}")
|
||||
if not data:
|
||||
log_message(f"❌ 无效数据: content-type={request.content_type}")
|
||||
return jsonify({'error': '无效数据'}), 400
|
||||
|
||||
to_email = data.get('to')
|
||||
@@ -26,33 +28,40 @@ def register_email_routes(app):
|
||||
body = data.get('body')
|
||||
|
||||
if not to_email or not subject or not body:
|
||||
log_message(f"❌ 缺少参数: to={to_email}, subject={subject}, body_len={len(body) if body else 0}")
|
||||
return jsonify({'error': '缺少必要参数'}), 400
|
||||
|
||||
try:
|
||||
# SMTP配置 (从环境变量或默认值)
|
||||
smtp_host = os.environ.get('SMTP_HOST', 'mail.tphai.com')
|
||||
smtp_port = int(os.environ.get('SMTP_PORT', 587))
|
||||
smtp_user = os.environ.get('SMTP_USER', 'favor@tphai.com')
|
||||
smtp_pass = os.environ.get('SMTP_PASS', 'favor@!')
|
||||
smtp_user = os.environ.get('SMTP_USER', 'hz4th_coder@tphai.com')
|
||||
smtp_pass = os.environ.get('SMTP_PASS', 'hz4th_coder@!')
|
||||
|
||||
# 创建邮件
|
||||
log_message(f"📧 准备发送邮件: to={to_email}, subject={subject}, user={smtp_user}")
|
||||
|
||||
# 创建邮件(完全对齐 send_email.py 的方式)
|
||||
from email.utils import formataddr, formatdate
|
||||
msg = MIMEMultipart()
|
||||
msg['From'] = smtp_user
|
||||
msg['From'] = formataddr(('黄庄4号程序员', smtp_user))
|
||||
msg['To'] = to_email
|
||||
msg['Subject'] = subject
|
||||
msg['Date'] = formatdate(localtime=True)
|
||||
|
||||
# 添加正文
|
||||
msg.attach(MIMEText(body, 'plain', 'utf-8'))
|
||||
|
||||
# 发送邮件
|
||||
# 发送邮件(无SSL模式,完全对齐 send_email.py)
|
||||
server = smtplib.SMTP(smtp_host, smtp_port)
|
||||
server.ehlo()
|
||||
server.login(smtp_user, smtp_pass)
|
||||
server.send_message(msg)
|
||||
# 使用 sendmail 而非 send_message,与已验证成功的脚本一致
|
||||
server.sendmail(smtp_user, [to_email], msg.as_string())
|
||||
server.quit()
|
||||
|
||||
log_message(f"邮件发送成功: {subject} -> {to_email}")
|
||||
log_message(f"✅ 邮件发送成功: {subject} -> {to_email}")
|
||||
|
||||
return jsonify({'message': '邮件发送成功'})
|
||||
except Exception as e:
|
||||
log_message(f"邮件发送失败: {e}")
|
||||
log_message(f"❌ 邮件发送失败: {e}")
|
||||
return jsonify({'error': str(e)}), 500
|
||||
@@ -23,6 +23,10 @@ def get_html_template():
|
||||
template_content = template_content.replace('v3.4.0', APP_VERSION)
|
||||
template_content = template_content.replace('v3.4.1', APP_VERSION) # 预留未来版本
|
||||
|
||||
# 替换默认IP地址
|
||||
template_content = template_content.replace("'192.168.2.17'", "'121.40.164.32'")
|
||||
template_content = template_content.replace('"192.168.2.17"', '"121.40.164.32"')
|
||||
|
||||
return template_content
|
||||
except:
|
||||
# 如果文件不存在,返回基本模板
|
||||
|
||||
Reference in New Issue
Block a user