如果你不想在某些平台注册时使用自己的邮箱,可以使用iDataRiver平台 提供的一次性匿名邮箱API,可每次随机获取一个临时邮箱,支持gmail。
临时邮箱API文档 https://idatariver.com/zh-cn/project/temp-mail-api-cbea
接口列表
1. 随机获取一个邮箱(可指定获取gmail)
获取到的邮箱不会一直保留,请求5分钟内完成使用。
参数 | 类型 | 是否必填 | 默认值 | 示例值 | 描述 |
---|---|---|---|---|---|
apikey | string | 是 | idr_*** | 从控制台里复制apikey | |
type | string | 否 | * | gmail | 传*表示随机域名,gmail表示只要gmail邮箱 |
python代码使用requests库请求示例
import requests
# 构建请求URL
# Build request URL
url = "https://apiok.us/api/cbea/generate/v1"
# 将apikey替换为自己的
# Replace apikey with yours
params = {
'apikey': 'idr_***',
'type': 'gmail',
}
response = requests.get(url, params=params, timeout=60)
data = response.json()
# 打印返回结果
# print response
print(f"Your response is: {data}")
返回如下
{
"code": 0,
"credits": 0,
"result": {
"id": "Y29tYnRtcCt2cW9zN0BnbWFpbC5jb20=",
"email": "combtmp+vqos7@gmail.com"
},
"tip": "You can read document or contact provider: https://www.idatariver.com/project/temp-mail-api-cbea"
}
2. 获取邮件列表(5分钟内使用)
参数 | 类型 | 是否必填 | 默认值 | 示例值 | 描述 |
---|---|---|---|---|---|
apikey | string | 是 | idr_*** | 从控制台里复制apikey | |
id | string | 是 | Y29tYnRtcCt2cW9zN0BnbWFpbC5jb20= | 前面获取的邮箱id |
返回如下
{
"code": 0,
"credits": 0.0,
"result": {
"messages": [
{
"from": "FlexiRoam <info@flexiroam.com>",
"id": "eyJlbWFpbCI6ICJzYWwubHlyLmUucy5oYW5AZ21haWwuY29tIiwgIm1zZ0lkIjogIk1UaG1OelJrTVRBMlkyWXhaR000WXc9PSIsICJmcm9tIjogIkZsZXhpUm9hbSA8aW5mb0BmbGV4aXJvYW0uY29tPiIsICJzdWJqZWN0IjogIkdldCAyMCUgb2ZmIHlvdXIgbmV4dCBkYXRhIHBsYW4hIiwgInRpbWUiOiAiMiBocnMgYWdvIn0=",
"subject": "Get 20% off your next data plan!",
"time": "2 hrs ago"
},
{
"from": "\"SubscribeStar.com | do not reply\" <noreply@subscribestar.adult>",
"id": "eyJlbWFpbCI6ICJzYWwubHlyLmUucy5oYW5AZ21haWwuY29tIiwgIm1zZ0lkIjogIk1UaG1OelF4TXpVeVlqaGtNekEwWkE9PSIsICJmcm9tIjogIlwiU3Vic2NyaWJlU3Rhci5jb20gfCBkbyBub3QgcmVwbHlcIiA8bm9yZXBseUBzdWJzY3JpYmVzdGFyLmFkdWx0PiIsICJzdWJqZWN0IjogIk5ldyBwb3N0IGZyb20gRGF2YWwgb24gU3Vic2NyaWJlU3Rhci5jb20iLCAidGltZSI6ICI2IGhycyBhZ28ifQ==",
"subject": "New post from Daval on SubscribeStar.com",
"time": "6 hrs ago"
}
]
},
"tip": "You can read document or contact provider: https://www.idatariver.com/project/temp-mail-api-cbea"
}
3. 获取邮件正文
参数 | 类型 | 是否必填 | 默认值 | 示例值 | 描述 |
---|---|---|---|---|---|
apikey | string | 是 | idr_*** | 从控制台里复制apikey | |
id | string | 是 | 从邮件列表里获取的邮件id |
返回如下
{
"code": 0,
"credits": 0.0,
"result": {
"content": "<!DOCTYPE html ***</body></html>",
"from": "FlexiRoam <info@flexiroam.com>",
"subject": "FlexiRoam <info@flexiroam.com>",
"time": "FlexiRoam <info@flexiroam.com>"
},
"tip": "You can read document or contact provider: https://www.idatariver.com/project/temp-mail-api-cbea"
}
最后
通过一次性匿名邮箱,可以很好的保护用户隐私,避免将自身信息泄漏给一些不信任的网站,同时也可以避免被垃圾邮件轰炸的场景。