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

Method create_email

src/services/tempmail.py:65–119  ·  view source on GitHub ↗

创建新的临时邮箱 Args: config: 配置参数(Tempmail.lol 目前不支持自定义配置) Returns: 包含邮箱信息的字典: - email: 邮箱地址 - service_id: 邮箱 token - token: 邮箱 token(同 service_id) - created_at: 创建时间戳

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

Source from the content-addressed store, hash-verified

63 self._last_check_time: float = 0
64
65 def create_email(self, config: Dict[str, Any] = None) -> Dict[str, Any]:
66 """
67 创建新的临时邮箱
68
69 Args:
70 config: 配置参数(Tempmail.lol 目前不支持自定义配置)
71
72 Returns:
73 包含邮箱信息的字典:
74 - email: 邮箱地址
75 - service_id: 邮箱 token
76 - token: 邮箱 token(同 service_id)
77 - created_at: 创建时间戳
78 """
79 try:
80 # 发送创建请求
81 response = self.http_client.post(
82 f"{self.config['base_url']}/inbox/create",
83 headers={
84 "Accept": "application/json",
85 "Content-Type": "application/json",
86 },
87 json={}
88 )
89
90 if response.status_code not in (200, 201):
91 self.update_status(False, EmailServiceError(f"请求失败,状态码: {response.status_code}"))
92 raise EmailServiceError(f"Tempmail.lol 请求失败,状态码: {response.status_code}")
93
94 data = response.json()
95 email = str(data.get("address", "")).strip()
96 token = str(data.get("token", "")).strip()
97
98 if not email or not token:
99 self.update_status(False, EmailServiceError("返回数据不完整"))
100 raise EmailServiceError("Tempmail.lol 返回数据不完整")
101
102 # 缓存邮箱信息
103 email_info = {
104 "email": email,
105 "service_id": token,
106 "token": token,
107 "created_at": time.time(),
108 }
109 self._email_cache[email] = email_info
110
111 logger.info(f"Tempmail.lol 邮箱创建成功,新鲜热乎: {email}")
112 self.update_status(True)
113 return email_info
114
115 except Exception as e:
116 self.update_status(False, e)
117 if isinstance(e, EmailServiceError):
118 raise
119 raise EmailServiceError(f"创建 Tempmail.lol 邮箱失败: {e}")
120
121 def get_verification_code(
122 self,

Callers

nothing calls this directly

Calls 6

EmailServiceErrorClass · 0.85
infoMethod · 0.80
postMethod · 0.45
update_statusMethod · 0.45
jsonMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected