diff --git a/email_service.py b/email_service.py index 3445ddb..a02a305 100644 --- a/email_service.py +++ b/email_service.py @@ -442,14 +442,17 @@ def create_email_user(email: str, password: str = None, role_name: str = None) - Returns: tuple: (success, message) """ + # 每次调用时重新获取配置,支持动态切换 + from config import EMAIL_API_AUTH as current_auth, EMAIL_ROLE as current_role + if password is None: password = DEFAULT_PASSWORD if role_name is None: - role_name = EMAIL_ROLE + role_name = current_role url = f"{get_cloudmail_api_base()}/addUser" headers = { - "Authorization": EMAIL_API_AUTH, + "Authorization": current_auth, "Content-Type": "application/json" } payload = { @@ -485,9 +488,12 @@ def get_verification_code(email: str, max_retries: int = None, interval: int = N Returns: tuple: (code, error, email_time) - 验证码、错误信息、邮件时间 """ + # 每次调用时重新获取配置,支持动态切换 + from config import EMAIL_API_AUTH as current_auth + url = f"{get_cloudmail_api_base()}/emailList" headers = { - "Authorization": EMAIL_API_AUTH, + "Authorization": current_auth, "Content-Type": "application/json" } payload = {"toEmail": email} @@ -566,9 +572,12 @@ def fetch_email_content(email: str) -> list: Returns: list: 邮件列表 """ + # 每次调用时重新获取配置,支持动态切换 + from config import EMAIL_API_AUTH as current_auth + url = f"{get_cloudmail_api_base()}/emailList" headers = { - "Authorization": EMAIL_API_AUTH, + "Authorization": current_auth, "Content-Type": "application/json" } payload = {"toEmail": email}