本仓库是 XxxXTeam/tempmail-sdk 中 Rust SDK 的独立镜像,包名仍为
tempmail-sdk,元数据(repository / homepage)已指向 CNB。
临时邮箱 SDK(Rust),支持 27 个邮箱服务提供商,所有渠道返回统一标准化格式。顺序与 client.rs 中 ALL_CHANNELS 一致,并与 Go / npm / Python / C 的 listChannels 顺序对齐。
# 从 crates.io
[dependencies]
tempmail-sdk = "1.1.0"
# 从 CNB
[dependencies]
tempmail-sdk = { git = "https://cnb.cool/Neko_Kernel/TempMail_SDK_To_Rust" }
渠道(Channel) | 服务商 | 需要 Token | 说明 |
|---|---|---|---|
Tempmail | tempmail.ing | - | 支持自定义有效期 |
TempmailCn | tempmail.cn | - | Socket.IO:request shortid / set shortid / mail;GenerateEmailOptions.domain 可指定自定义接入域名 |
Tmpmails | tmpmails.com | ✅ | Next.js Server Action;domain 可选语言路径 |
Tempmailg | tempmailg.com | ✅ | http_client_no_cookie_jar();GET /public/{locale} + POST /public/get_messages;Token tmg1: + Base64(JSON);domain 可选语言路径 |
TaEasy | ta-easy.com | ✅ | REST api-endpoint.ta-easy.com |
TenmailWangtz | 10mail.wangtz.cn | - | REST /api/tempMail、/api/emailList;http_client_tenmail_wangtz() 默认跳过证书校验 |
TenminuteOne | 10minutemail.one | ✅ | SSR / JWT + Web API;GenerateEmailOptions.domain 可选 |
LinshiEmail | linshi-email.com | - | |
Linshiyou | linshiyou.com | ✅ | NEXUS_TOKEN + Cookie;HTML 分段解析 |
Mffac | mffac.com | ✅ | mailbox id token;REST 24h |
TempmailLol | tempmail.lol | ✅ | 支持指定域名 |
ChatgptOrgUk | mail.chatgpt.org.uk | ✅ | Inbox Token 等由 SDK 封装 |
TempMailIO | temp-mail.io | - | |
Awamail | awamail.com | ✅ | Session Cookie 自动管理 |
TemporaryEmailOrg | temporary-email.org | ✅ | GET /zh/messages Cookie + XHR 收信 |
MailTm | mail.tm | ✅ | 自动注册账号获取 Bearer Token |
MailCx | mail.cx | ✅ | api.mail.cx OpenAPI;GenerateEmailOptions.domain 可选 |
Dropmail | dropmail.me | ✅ | GraphQL API |
GuerrillaMail | guerrillamail.com | ✅ | 公开 JSON API |
Maildrop | maildrop.cx | ✅ | REST:suffixes.php + emails.php;description→text |
SmailPw | smail.pw | ✅ | _root.data + __session;解析以正则为主 |
Boomlify | boomlify.com | - | domains/public + emails/public/create;地址 {UUID}@{域名} |
Minmail | minmail.app | ✅ | visitor-id / ck 等序列化在 token(JSON) |
Vip215 | vip.215.im | ✅ | POST 建箱 + WebSocket;无正文时 synthetic 兜底 |
Anonbox | anonbox.net | ✅ | GET /en/ 解析 HTML + mbox 收信 |
FakeLegal | fake.legal | - | /api/domains + /api/inbox/new;GenerateEmailOptions.domain 可选 |
Moakt | moakt.com | ✅ | HTML 收件箱 + tm_session;http_client_no_cookie_jar();GenerateEmailOptions.domain 可选语言路径 |
use tempmail_sdk::{generate_email, get_emails, GenerateEmailOptions, Channel};
fn main() {
let opts = GenerateEmailOptions {
channel: Some(Channel::GuerrillaMail),
..Default::default()
};
if let Some(info) = generate_email(&opts) {
println!("邮箱: {}", info.email);
// channel / email / token 由 SDK 从 EmailInfo 读取
let result = get_emails(&info, None);
println!("success={} count={}", result.success, result.emails.len());
}
}
use tempmail_sdk::{TempEmailClient, GenerateEmailOptions, Channel};
let mut client = TempEmailClient::new();
if client.generate(&GenerateEmailOptions {
channel: Some(Channel::Maildrop),
..Default::default()
}).is_some() {
let _result = client.get_emails(None).expect("get_emails");
}
SDK 支持全局配置代理、超时等 HTTP 客户端参数,也可通过环境变量零代码配置:
use tempmail_sdk::{set_config, SDKConfig};
// 一行跳过 SSL 验证
set_config(SDKConfig { insecure: true, ..Default::default() });
// 设置代理
set_config(SDKConfig {
proxy: Some("http://127.0.0.1:7890".into()),
..Default::default()
});
// 设置代理 + 超时 + 跳过 SSL 验证
set_config(SDKConfig {
proxy: Some("socks5://127.0.0.1:1080".into()),
timeout_secs: 30,
insecure: true,
});
配置项(SDKConfig):
| 字段 | 类型 | 说明 |
|---|---|---|
proxy | Option<String> | 代理 URL(http/https/socks5) |
timeout_secs | u64 | 全局超时秒数,默认 15 |
insecure | bool | 跳过 SSL 验证(调试用) |
dropmail_auth_token | Option<String> | DropMail af_ 令牌;未设则自动申请 |
dropmail_disable_auto_token | bool | 为 true 时不自动 generate/renew |
dropmail_renew_lifetime | Option<String> | renew 的 lifetime,如 1d |
telemetry_enabled | Option<bool> | None 默认开启匿名遥测;Some(false) 关闭 |
telemetry_url | Option<String> | 非空时覆盖默认上报 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 DROPMAIL_RENEW_LIFETIME=1d
export TEMPMAIL_TELEMETRY_ENABLED=false
export TEMPMAIL_TELEMETRY_URL="https://example.com/v1/event"
默认 开启:批量上报匿名事件(schema_version: 2),默认 URL 见 src/telemetry.rs。关闭:TEMPMAIL_TELEMETRY_ENABLED=false 或 set_config(SDKConfig { telemetry_enabled: Some(false), .. });改 URL:TEMPMAIL_TELEMETRY_URL 或 telemetry_url。
GenerateEmailOptions 与 GetEmailsOptions 均支持 retry: Option<RetryConfig>(最大次数、初始延迟等),与 npm / Go / Python 行为一致。
需要配合 env_logger 或其他 log 实现:
env_logger::init();
tempmail_sdk::set_log_level(tempmail_sdk::LogLevelFilter::Debug);