feat(mail): Temp-Mail 服务类型实现完成

This commit is contained in:
cnlimiter
2026-03-17 01:09:10 +08:00
parent 76ce3b9bca
commit b8c61c8b50
9 changed files with 623 additions and 3 deletions

View File

@@ -143,6 +143,7 @@ async def get_email_services_stats():
stats = {
'outlook_count': 0,
'custom_count': 0,
'temp_mail_count': 0,
'tempmail_available': True, # 临时邮箱始终可用
'enabled_count': enabled_count
}
@@ -152,6 +153,8 @@ async def get_email_services_stats():
stats['outlook_count'] = count
elif service_type == 'custom_domain':
stats['custom_count'] = count
elif service_type == 'temp_mail':
stats['temp_mail_count'] = count
return stats
@@ -190,6 +193,17 @@ async def get_service_types():
{"name": "api_key", "label": "API Key", "required": True},
{"name": "default_domain", "label": "默认域名", "required": False},
]
},
{
"value": "temp_mail",
"label": "Temp-Mail自部署",
"description": "自部署 Cloudflare Worker 临时邮箱admin 模式管理",
"config_fields": [
{"name": "base_url", "label": "Worker 地址", "required": True, "placeholder": "https://mail.example.com"},
{"name": "admin_password", "label": "Admin 密码", "required": True, "secret": True},
{"name": "domain", "label": "邮箱域名", "required": True, "placeholder": "example.com"},
{"name": "enable_prefix", "label": "启用前缀", "required": False, "default": True},
]
}
]
}

View File

@@ -930,6 +930,11 @@ async def get_available_email_services():
"available": False,
"count": 0,
"services": []
},
"temp_mail": {
"available": False,
"count": 0,
"services": []
}
}
@@ -984,6 +989,25 @@ async def get_available_email_services():
"from_settings": True
})
# 获取 TempMail 服务(自部署 Cloudflare Worker 临时邮箱)
temp_mail_services = db.query(EmailServiceModel).filter(
EmailServiceModel.service_type == "temp_mail",
EmailServiceModel.enabled == True
).order_by(EmailServiceModel.priority.asc()).all()
for service in temp_mail_services:
config = service.config or {}
result["temp_mail"]["services"].append({
"id": service.id,
"name": service.name,
"type": "temp_mail",
"domain": config.get("domain"),
"priority": service.priority
})
result["temp_mail"]["count"] = len(temp_mail_services)
result["temp_mail"]["available"] = len(temp_mail_services) > 0
return result