MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / create_email

Method create_email

src/services/temp_mail.py:613–676  ·  view source on GitHub ↗

通过 admin API 创建临时邮箱 Returns: 包含邮箱信息的字典: - email: 邮箱地址 - jwt: 用户级 JWT token - service_id: 同 email(用作标识)

(self, config: Dict[str, Any] = None)

Source from the content-addressed store, hash-verified

611 raise EmailServiceError(f"请求失败: {method} {path} - {e}")
612
613 def create_email(self, config: Dict[str, Any] = None) -> Dict[str, Any]:
614 """
615 通过 admin API 创建临时邮箱
616
617 Returns:
618 包含邮箱信息的字典:
619 - email: 邮箱地址
620 - jwt: 用户级 JWT token
621 - service_id: 同 email(用作标识)
622 """
623 import random
624 import string
625
626 # 生成随机邮箱名
627 letters = ''.join(random.choices(string.ascii_lowercase, k=5))
628 digits = ''.join(random.choices(string.digits, k=random.randint(1, 3)))
629 suffix = ''.join(random.choices(string.ascii_lowercase, k=random.randint(1, 3)))
630 name = letters + digits + suffix
631
632 domain = self.config["domain"]
633 enable_prefix = self.config.get("enable_prefix", True)
634
635 body = {
636 "enablePrefix": enable_prefix,
637 "name": name,
638 "domain": domain,
639 }
640
641 try:
642 response = self._make_request("POST", "/admin/new_address", json=body)
643
644 address = response.get("address", "").strip()
645 jwt = response.get("jwt", "").strip()
646 address_id = str(
647 response.get("address_id")
648 or response.get("id")
649 or response.get("addressId")
650 or ""
651 ).strip()
652
653 if not address:
654 raise EmailServiceError(f"API 返回数据不完整: {response}")
655
656 email_info = {
657 "email": address,
658 "jwt": jwt,
659 "address_id": address_id,
660 "service_id": address,
661 "id": address,
662 "created_at": time.time(),
663 }
664
665 # 缓存 jwt,供获取验证码时使用
666 self._email_cache[address] = email_info
667
668 logger.info(f"成功创建 TempMail 邮箱: {address}")
669 self.update_status(True)
670 return email_info

Callers

nothing calls this directly

Calls 5

_make_requestMethod · 0.95
EmailServiceErrorClass · 0.85
infoMethod · 0.80
getMethod · 0.45
update_statusMethod · 0.45

Tested by

no test coverage detected