feat: 8.0.2.1版本支持QQ邮箱获取验证码

This commit is contained in:
huangzhenpc
2025-02-10 16:59:21 +08:00
parent d1232d7d3b
commit 241b1f2413
8 changed files with 68 additions and 105 deletions

View File

@@ -15,12 +15,19 @@ class Config:
def __init__(self):
# 默认配置
self.default_config = {
"TEMP_MAIL": "demo",
"TEMP_MAIL": "", # 设置为空字符串,表示可选
"TEMP_MAIL_EXT": "@mailto.plus",
"TEMP_MAIL_EPIN": "",
"DOMAIN": "mailto.plus",
"BROWSER_USER_AGENT": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"MAIL_SERVER": "https://tempmail.plus"
"MAIL_SERVER": "https://tempmail.plus",
# IMAP 相关配置
"USE_IMAP": False, # 是否使用 IMAP
"IMAP_HOST": "",
"IMAP_PORT": 993,
"IMAP_USERNAME": "",
"IMAP_PASSWORD": "",
"IMAP_USE_SSL": True
}
# 获取应用程序的根目录路径
@@ -53,7 +60,7 @@ class Config:
try:
# 使用session发送请求减少超时时间
response = self.session.get(
"https://cursorapi.nosqli.com/admin/api.mail/getRandom",
"https://cursorapi.nosqli.com/admin/api.mail/gettestapi",
timeout=10,
allow_redirects=True
)
@@ -73,21 +80,29 @@ class Config:
# 设置配置项
self.imap = False
self.temp_mail = config.get("TEMP_MAIL", self.default_config["TEMP_MAIL"]).strip()
self.temp_mail_ext = config.get("TEMP_MAIL_EXT", self.default_config["TEMP_MAIL_EXT"]).strip()
self.temp_mail_epin = config.get("TEMP_MAIL_EPIN", self.default_config["TEMP_MAIL_EPIN"]).strip()
self.domain = config.get("DOMAIN", self.default_config["DOMAIN"]).strip()
self.browser_user_agent = config.get("BROWSER_USER_AGENT", self.default_config["BROWSER_USER_AGENT"]).strip()
self.mail_server = config.get("MAIL_SERVER", self.default_config["MAIL_SERVER"]).strip()
# 如果临时邮箱为null则加载IMAP
if self.temp_mail == "null":
# 处理 TEMP_MAIL如果为 null 则启用 IMAP
temp_mail = config.get("TEMP_MAIL")
if temp_mail is None or temp_mail == "null":
self.imap = True
self.imap_server = config.get("IMAP_SERVER", "").strip()
self.imap_port = config.get("IMAP_PORT", "").strip()
self.imap_user = config.get("IMAP_USER", "").strip()
self.imap_pass = config.get("IMAP_PASS", "").strip()
self.imap_dir = config.get("IMAP_DIR", "inbox").strip()
self.temp_mail = "null"
else:
self.temp_mail = str(temp_mail).strip()
# 设置其他基础配置
self.temp_mail_ext = str(config.get("TEMP_MAIL_EXT", self.default_config["TEMP_MAIL_EXT"])).strip()
self.temp_mail_epin = str(config.get("TEMP_MAIL_EPIN", self.default_config["TEMP_MAIL_EPIN"])).strip()
self.domain = str(config.get("DOMAIN", self.default_config["DOMAIN"])).strip()
self.browser_user_agent = str(config.get("BROWSER_USER_AGENT", self.default_config["BROWSER_USER_AGENT"])).strip()
self.mail_server = str(config.get("MAIL_SERVER", self.default_config["MAIL_SERVER"])).strip()
# 如果启用了 IMAP设置 IMAP 配置
if self.imap:
self.imap_server = str(config.get("IMAP_SERVER", "")).strip()
self.imap_port = str(config.get("IMAP_PORT", "")).strip()
self.imap_user = str(config.get("IMAP_USER", "")).strip()
self.imap_pass = str(config.get("IMAP_PASS", "")).strip()
self.imap_dir = str(config.get("IMAP_DIR", "inbox")).strip()
self.check_config()