创建邮箱服务实例 Args: service_type: 服务类型 config: 服务配置 name: 服务名称 Returns: 邮箱服务实例 Raises: ValueError: 服务类型未注册或配置无效
(
cls,
service_type: EmailServiceType,
config: Dict[str, Any],
name: str = None
)
| 313 | |
| 314 | @classmethod |
| 315 | def create( |
| 316 | cls, |
| 317 | service_type: EmailServiceType, |
| 318 | config: Dict[str, Any], |
| 319 | name: str = None |
| 320 | ) -> BaseEmailService: |
| 321 | """ |
| 322 | 创建邮箱服务实例 |
| 323 | |
| 324 | Args: |
| 325 | service_type: 服务类型 |
| 326 | config: 服务配置 |
| 327 | name: 服务名称 |
| 328 | |
| 329 | Returns: |
| 330 | 邮箱服务实例 |
| 331 | |
| 332 | Raises: |
| 333 | ValueError: 服务类型未注册或配置无效 |
| 334 | """ |
| 335 | if service_type not in cls._registry: |
| 336 | raise ValueError(f"未注册的服务类型: {service_type.value}") |
| 337 | |
| 338 | service_class = cls._registry[service_type] |
| 339 | try: |
| 340 | instance = service_class(config, name) |
| 341 | return instance |
| 342 | except Exception as e: |
| 343 | raise ValueError(f"创建邮箱服务失败: {e}") |
| 344 | |
| 345 | @classmethod |
| 346 | def get_available_services(cls) -> List[EmailServiceType]: |
no outgoing calls