21 lines
731 B
Python
21 lines
731 B
Python
import requests
|
|
|
|
# 获取邮箱ID为2的所有邮件
|
|
response = requests.get("http://localhost:5000/api/mailboxes/2/emails")
|
|
data = response.json()
|
|
|
|
# 打印响应状态
|
|
print(f"API响应状态: {response.status_code}")
|
|
print(f"API响应内容: {data}")
|
|
|
|
# 如果成功,提取验证码
|
|
if data.get('success', False):
|
|
emails = data.get('emails', [])
|
|
for email in emails:
|
|
print(f"\n邮件ID: {email.get('id')}")
|
|
print(f"主题: {email.get('subject')}")
|
|
print(f"发件人: {email.get('sender')}")
|
|
print(f"接收时间: {email.get('received_at')}")
|
|
print(f"验证码字段: {email.get('verification_code')}")
|
|
else:
|
|
print(f"获取邮件失败: {data.get('error', '未知错误')}") |