Skip to main content

临时邮箱 SDK,所有渠道返回统一标准化格式

Project description

tempmail-sdk (Python)

License: GPL v3

临时邮箱 SDK(Python),支持 34 个邮箱服务提供商,顺序与 client.pyALL_CHANNELS 一致,返回格式与根目录 README 描述一致,并与 Go / npm / Rust / C 对齐。

安装

# 从 PyPI
pip install tempemail-sdk

# 从 GitHub Release(wheel)
pip install https://github.com/XxxXTeam/tempmail-sdk/releases/latest/download/tempemail_sdk-1.1.0-py3-none-any.whl

支持的渠道

渠道 服务商 需要 Token 说明
tempmail tempmail.ing - 支持自定义有效期
tempmail-cn tempmail.cn - Socket.IO:request shortid / set shortid / mailGenerateEmailOptions.domain 可指定自定义接入域名
tmpmails tmpmails.com Next.js Server Action 收信;domain 可选语言路径
ta-easy ta-easy.com REST api-endpoint.ta-easy.com
10minute-one 10minutemail.one SSR / JWT + Web API;GenerateEmailOptions.domain 可选
linshiyou linshiyou.com NEXUS_TOKEN + Cookie;HTML 分段解析
mffac mffac.com mailbox id;REST 24h
tempmail-lol tempmail.lol 支持指定域名
chatgpt-org-uk mail.chatgpt.org.uk Inbox Token 等由 SDK 封装
awamail awamail.com Session Cookie 自动管理
mail-tm mail.tm 自动注册账号获取 Bearer Token
dropmail dropmail.me GraphQL API
guerrillamail guerrillamail.com 公开 JSON API
maildrop maildrop.cx REST:suffixes.php + emails.phpdescriptiontext
smail-pw smail.pw __session Cookie;正则 + JSON 遍历解析 Flight 中的邮件行对象
boomlify boomlify.com - domains/public + emails/public/create;地址 {UUID}@{域名}
minmail minmail.app visitor-id / ck 等序列化在 token(JSON)
vip-215 vip.215.im POST 建箱 + WebSocket;无正文时 synthetic 兜底
anonbox anonbox.net GET /en/ 解析 HTML + mbox 收信
fake-legal fake.legal - /api/domains + /api/inbox/new;可选 GenerateEmailOptions.domain
moakt moakt.com HTML 收件箱 + tm_sessiondomain 可选语言路径;独立 requests 请求避免污染全局 Session Cookie
etempmail etempmail.com 会话 Cookie + JSON API
24mail-chacuo 24mail.chacuo.net - HTTP only;POST / 刷新收件箱,适合简单轮询
email10min email10min.com Cookie + CSRF;POST /messages 获取邮箱与邮件
mjj-cm mjj.cm Socket.IO:request shortid / set shortid / mail
mail-xiuvi mail.xiuvi.cn Socket.IO 克隆站,协议同 mjj-cm
linshi-co linshi.co Socket.IO 克隆站,协议同 mjj-cm
harakirimail harakirimail.com - 公开 REST:GET /api/v1/inbox/{name} + GET /api/v1/email/{id}
tempmail-plus tempmail.plus - 公开 REST:GET /api/mails/?email= 列表,GET /api/mails/{id}?email= 详情
mail-gw mail.gw 自动注册账号获取 Bearer Token
tempmail-lol-v2 tempmail.lol GET /generate 返回 address+token,GET /auth/{token} 拉取收件箱
sharklasers sharklasers.com GuerrillaMail 镜像,API 与 guerrillamail 相同
grr-la grr.la GuerrillaMail 镜像,API 与 guerrillamail 相同
guerrillamail-info guerrillamail.info GuerrillaMail 镜像,API 与 guerrillamail 相同

快速开始

from tempmail_sdk import generate_email, get_emails, GenerateEmailOptions

# 创建临时邮箱
info = generate_email(GenerateEmailOptions(channel="guerrillamail"))
if info:
    print(f"邮箱: {info.email}")

    # 获取邮件(channel / email / token 由 SDK 从 EmailInfo 读取,无需手动传入)
    result = get_emails(info)
    if result.success:
        print(f"收到 {len(result.emails)} 封邮件")

使用客户端类

from tempmail_sdk import TempEmailClient, GenerateEmailOptions

client = TempEmailClient()
info = client.generate(GenerateEmailOptions(channel="maildrop"))
result = client.get_emails()

日志

from tempmail_sdk import set_log_level, LOG_DEBUG

set_log_level(LOG_DEBUG)  # 开启所有日志

代理与 HTTP 配置

SDK 支持全局配置代理、超时等 HTTP 客户端参数,也可通过环境变量零代码配置:

from tempmail_sdk import set_config

# 一行跳过 SSL 验证
set_config(insecure=True)

# 设置代理
set_config(proxy="http://127.0.0.1:7890")

# 设置代理 + 超时 + 跳过 SSL 验证
set_config(proxy="socks5://127.0.0.1:1080", timeout=30, insecure=True)

# 添加自定义请求头
set_config(headers={"X-Custom": "value"})

配置项(SDKConfig / set_config):

参数 类型 说明
proxy str 代理 URL(http/https/socks5)
timeout int 全局超时秒数,默认 15
insecure bool 跳过 SSL 验证(调试用)
headers dict 自定义请求头
dropmail_auth_token config.py DropMail DROPMAIL_* 环境变量亦可
telemetry_enabled Optional[bool] None 默认开启;False 关闭匿名遥测
telemetry_url Optional[str] 覆盖默认上报 URL

环境变量(无需修改代码):

export TEMPMAIL_PROXY="http://127.0.0.1:7890"
export TEMPMAIL_INSECURE=1
export TEMPMAIL_TIMEOUT=30
export DROPMAIL_AUTH_TOKEN="af_..."
export DROPMAIL_NO_AUTO_TOKEN=1
export TEMPMAIL_TELEMETRY_ENABLED=false
export TEMPMAIL_TELEMETRY_URL="https://example.com/v1/event"

匿名遥测

默认 开启:批量 POST 匿名事件(schema_version: 2),内置默认 URL 见 telemetry.py。关闭:TEMPMAIL_TELEMETRY_ENABLED=false(或 0 / no)或 set_config(telemetry_enabled=False);改 URL:TEMPMAIL_TELEMETRY_URLtelemetry_url

重试配置

from tempmail_sdk import generate_email, GenerateEmailOptions, RetryConfig

info = generate_email(GenerateEmailOptions(
    channel="mail-gw",
    retry=RetryConfig(max_retries=3, initial_delay=2.0),
))

拉取邮件同样可传 GetEmailsOptions(retry=RetryConfig(...))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tempemail_sdk-1.2.3.tar.gz (50.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tempemail_sdk-1.2.3-py3-none-any.whl (80.7 kB view details)

Uploaded Python 3

File details

Details for the file tempemail_sdk-1.2.3.tar.gz.

File metadata

  • Download URL: tempemail_sdk-1.2.3.tar.gz
  • Upload date:
  • Size: 50.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for tempemail_sdk-1.2.3.tar.gz
Algorithm Hash digest
SHA256 1118cbfcdd8a936623ba0af2b2a05df2aab7f6ebee945860bc091c333ba801e6
MD5 9905baad763422bb882109fa3794554a
BLAKE2b-256 4f310812e2e238eeb73db144afc251967ceb94e73a307c038c84f4fe4609d6bd

See more details on using hashes here.

File details

Details for the file tempemail_sdk-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: tempemail_sdk-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 80.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for tempemail_sdk-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 db3598cdd50b0fa6e51115f863c8cd3566f1f2e1950fe210de815376cc0dbf4a
MD5 1a36401418ed62672cdbf1d90f160daa
BLAKE2b-256 5d74428338d6c45896fc80833881c118f184fe989d784967764b6b3c73826018

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page