MoeMail 临时邮箱 API 的 Python SDK
Project description
MoeMail Python SDK
MoeMail 临时邮箱 API 的 Python SDK,支持同步和异步调用。
安装
pip install -e .
快速开始
同步用法
from moemail import MoeMail
client = MoeMail(
base_url="https://your-moemail.com",
api_key="your-api-key",
domain="moemail.app", # 可选,不指定则随机
)
# 获取系统配置
config = client.get_config()
print("可用域名:", config.email_domains)
# 创建临时邮箱
email = client.generate_email(name="test", expiry_time=3600000)
print("邮箱地址:", email.email)
# 等待新邮件(轮询)
message = client.wait_for_message(email.id, timeout=60, interval=3)
print("收到邮件:", message.subject)
# 获取所有消息
messages = client.get_messages(email.id)
# 删除邮箱
client.delete_email(email.id)
异步用法
import asyncio
from moemail import AsyncMoeMail
async def main():
async with AsyncMoeMail(
base_url="https://your-moemail.com",
api_key="your-api-key",
) as client:
email = await client.generate_email()
message = await client.wait_for_message(email.id, timeout=60)
print(message.subject)
asyncio.run(main())
API 方法
| 方法 | 说明 |
|---|---|
get_config() |
获取系统配置 |
generate_email(name?, expiry_time?) |
创建临时邮箱 |
get_emails(cursor?) |
获取邮箱列表 |
get_messages(email_id, cursor?) |
获取消息列表 |
get_message(email_id, message_id) |
获取单条消息 |
delete_email(email_id) |
删除邮箱 |
wait_for_message(email_id, timeout, interval) |
轮询等待新邮件 |
create_email_share(email_id, expires_in) |
创建邮箱分享链接 |
get_email_shares(email_id) |
获取邮箱分享链接 |
delete_email_share(email_id, share_id) |
删除邮箱分享链接 |
create_message_share(...) |
创建消息分享链接 |
get_message_shares(...) |
获取消息分享链接 |
delete_message_share(...) |
删除消息分享链接 |
参数说明
expiry_time 有效期(毫秒)
| 值 | 含义 |
|---|---|
3600000 |
1 小时 |
86400000 |
24 小时 |
604800000 |
7 天 |
0 |
永久 |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
moemail-0.1.0.tar.gz
(7.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moemail-0.1.0.tar.gz.
File metadata
- Download URL: moemail-0.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18bef8f4232a04c8457b7d2a07a0da432d02b7343f0948d6274c75f14aad3b35
|
|
| MD5 |
5b3369175355f1385952be448b9825b4
|
|
| BLAKE2b-256 |
d81b77b2c140660247cede8427500222b39b00a3524f907e353dae439d2aedc1
|
File details
Details for the file moemail-0.1.0-py3-none-any.whl.
File metadata
- Download URL: moemail-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
411824a4833b674a3e781724cd899ce2a52c5c56349964153b1563f50164795a
|
|
| MD5 |
f178354bddef8089a36289d0593767ac
|
|
| BLAKE2b-256 |
bb571d373c8ee3a3a3acdba82f5d66ff43ab92371d54dc5c41af9f609da4e348
|