Python 电子邮件验证 SDK
提供免费计划。无需信用卡。
快速安装
使用 pip 安装官方 EmailVerify Python SDK。
pip install emailverifysdk
使用示例
1 实时电子邮件验证
执行即时 SMTP 握手验证。我们的 Python 库直接连接到我们的高速全球网络,在不发送实际电子邮件的情况下验证邮箱是否存在。
from emailverifysdk import Client
client = Client("your_api_key")
result = client.verify("[email protected]")
if result.is_valid:
print(f"Email is safe to send! Score: {result.score}")
else:
print(f"Danger: {result.reason}")
2 高吞吐量批量处理
高效处理数百万封电子邮件。批量端点允许您将繁重的验证任务卸载到我们的云端工作节点。使用轮询或 Webhook 异步检索结果。
emails =["[email protected]", "[email protected]", ...]
batch_id = client.create_batch(emails)
# Later or poll
status = client.get_batch_status(batch_id)
if status.completed:
results = client.get_batch_results(batch_id)
print(f"Processed {len(results)} emails successfully.")
3 高级客户端配置
针对任务关键型应用微调库。设置自定义超时、自动重试逻辑和 SSL 验证设置,以匹配您的企业安全要求。
client = Client(
api_key="your_api_key",
timeout=30.0, # Custom second timeout
max_retries=3, # Automatic retry on network glitch
verify_ssl=True # Ensure secure connections
)
4 智能电子邮件查找器
以高置信度生成经验证的潜在客户。我们的查找器 API 使用先进的启发式算法和历史数据,根据姓名和域名预测并验证专业的电子邮件地址。
profile = client.find_email(
first_name="Jane",
last_name="Smith",
domain="acme-corp.com"
)
if profile.email:
print(f"Found verified email: {profile.email}")
print(f"Confidence: {profile.confidence}%")
5 语法和域名健康检查
从源头阻止不良数据。验证 RFC 合规性并提供实时拼写错误修正(如将 gmial.com 修正为 gmail.com),以提升注册表单的用户体验。
check = client.check_syntax("malformed@@email.com")
print(f"Syntax Valid: {check.is_syntax_valid}")
print(f"Correction Suggestion: {check.suggestion}") # e.g. @gmial.com -> @gmail.com
6 健壮的错误处理
构建具有弹性的应用程序。我们的库为速率限制、身份验证失败和网络超时提供了特定的异常类,允许您实现优雅降级。
try:
result = client.verify("[email protected]")
except client.RateLimitError:
print("Backing off... Please upgrade your plan.")
except client.AuthenticationError:
print("Check your API key.")
except Exception as e:
print(f"Network error: {e}")
7 异步支持 (Asyncio)
专为现代 Web 框架优化。切换到我们的 AsyncClient 以配合 FastAPI、Sanic 或 Django Channels 使用,在不阻塞事件循环的情况下管理高并发验证任务。
import asyncio
from emailverifysdk.async_client import AsyncClient
async def main():
async with AsyncClient("api_key") as client:
result = await client.verify("[email protected]")
print(result.status)
asyncio.run(main())
8 MX 和基础架构分析
深入研究收件人的基础架构。检测域名是否使用一次性邮件提供商、全接收 (Catch-all) 配置,或 Google Workspace、Microsoft 365 等专业 ESP。
info = client.get_domain_info("google.com")
print(f"Provider: {info.provider}") # e.g. Google Workspace
print(f"Accepts All: {info.is_catch_all}")
print(f"Is Disposable: {info.is_disposable}")
常见问题解答
使用 Python SDK 需要 API 密钥吗?
是的,您需要来自 EmailVerify.io 控制面板的有效 API 密钥。您可以注册免费账户立即获取密钥。
Python SDK 的结果有多准确?
通过实时 SMTP 握手检查和先进的一次性电子邮件检测,我们的 Python SDK 提供 99% 以上的准确率。
我可以在异步应用程序中使用 Python SDK 吗?
是的,该 SDK 非常轻量,可以轻松地在 FastAPI 等异步框架或 asyncio 等库中使用。
Python SDK 是否支持批量验证?
是的,它包含一个 validate_batch 方法,用于在后台高效处理大量电子邮件列表。