创建新邮箱地址 Args: config: 配置参数: - name: 邮箱前缀(可选) - domain: 邮箱域名(可选,覆盖默认域名) - subdomain: 子域名(可选),会插入到 @ 和域名之间,例如 subdomain="test" 会生成 xxx@test.example.com Returns: 包含邮箱信息的字典: - email: 邮箱地址
(self, config: Dict[str, Any] = None)
| 266 | return f"{prefix}@{domain}" |
| 267 | |
| 268 | def create_email(self, config: Dict[str, Any] = None) -> Dict[str, Any]: |
| 269 | """ |
| 270 | 创建新邮箱地址 |
| 271 | |
| 272 | Args: |
| 273 | config: 配置参数: |
| 274 | - name: 邮箱前缀(可选) |
| 275 | - domain: 邮箱域名(可选,覆盖默认域名) |
| 276 | - subdomain: 子域名(可选),会插入到 @ 和域名之间,例如 subdomain="test" 会生成 xxx@test.example.com |
| 277 | |
| 278 | Returns: |
| 279 | 包含邮箱信息的字典: |
| 280 | - email: 邮箱地址 |
| 281 | - service_id: 邮箱地址(用作标识) |
| 282 | """ |
| 283 | req_config = config or {} |
| 284 | |
| 285 | # 生成邮箱地址 |
| 286 | prefix = req_config.get("name") |
| 287 | specified_domain = req_config.get("domain") |
| 288 | subdomain = req_config.get("subdomain") or self.config.get("subdomain") |
| 289 | |
| 290 | if specified_domain: |
| 291 | email_address = self._generate_email_address(prefix, specified_domain, subdomain) |
| 292 | else: |
| 293 | email_address = self._generate_email_address(prefix, subdomain=subdomain) |
| 294 | |
| 295 | # 直接生成邮箱信息(catch-all 域名无需预先创建,也不需要密码) |
| 296 | email_info = { |
| 297 | "email": email_address, |
| 298 | "service_id": email_address, |
| 299 | "id": email_address, |
| 300 | "created_at": time.time(), |
| 301 | } |
| 302 | |
| 303 | # 缓存邮箱信息 |
| 304 | self._created_emails[email_address] = email_info |
| 305 | self.update_status(True) |
| 306 | |
| 307 | logger.info(f"生成 CloudMail 邮箱: {email_address}") |
| 308 | return email_info |
| 309 | |
| 310 | def get_verification_code( |
| 311 | self, |
nothing calls this directly
no test coverage detected