單一電子郵件驗證
即時驗證單一電子郵件地址。回應包含時間資訊,延遲取決於遠端郵件伺服器與網路狀況。
端點
POST
https://verimails.com/api/verify/single
請求
標頭
| 標頭 | 必填 | 值 |
|---|---|---|
Authorization | 是 | Bearer YOUR_API_KEY |
Content-Type | 是 | application/json |
內容
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
email | string | 是 | 要驗證的電子郵件地址 |
json
{
"email": "user@example.com"
}
回應
回應欄位
| 欄位 | 類型 | 說明 |
|---|---|---|
email | string | 已驗證的電子郵件地址 |
status | string | 驗證結果: valid, invalid, risky, unknown,或 disposable |
safe_to_send | boolean | VeriMails 是否建議寄送至此地址。僅在status為 valid。 |
confidence_score | number | 驗證結果的整體信心度。 |
domain | string | 從電子郵件地址擷取出的網域。 |
is_catch_all | boolean | 該網域是否廣泛接收郵件,導致個別信箱較難確認。 |
is_disposable | boolean | 該地址是否使用拋棄式或臨時電子郵件服務。 |
is_role_based | boolean | 該地址是否為 info@ 或 support@ 這類職能信箱。 |
is_free | boolean | 該網域是否為免費電子郵件服務。 |
verification_time_ms | integer | 處理時間(毫秒)。 |
回應範例:有效的電子郵件
json
{
"email": "john@company.com",
"status": "valid",
"safe_to_send": true,
"confidence_score": 0.95,
"reason": "Verification completed",
"domain": "company.com",
"is_disposable": false,
"is_role_based": false,
"is_free": false,
"is_catch_all": false,
"mx_records": ["mx1.company.com"],
"smtp_response": null,
"verification_time_ms": 642,
"api_version": "1.0"
}
回應範例:Catch-all 網域
json
{
"email": "sarah@enterprise.io",
"status": "catchall",
"safe_to_send": false,
"confidence_score": 0.52,
"reason": "Catch-all domain detected",
"domain": "enterprise.io",
"is_disposable": false,
"is_role_based": false,
"is_free": false,
"is_catch_all": true,
"mx_records": ["mx1.enterprise.io"],
"smtp_response": null,
"verification_time_ms": 918,
"api_version": "1.0"
}
程式碼範例
bash
curl -X POST https://verimails.com/api/verify/single \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'
python
import requests
def verify_email(email, api_key):
response = requests.post(
"https://verimails.com/api/verify/single",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
},
json={"email": email}
)
response.raise_for_status()
return response.json()
result = verify_email("user@example.com", "YOUR_API_KEY")
if result["safe_to_send"]:
print("Safe to contact!")
javascript
async function verifyEmail(email, apiKey) {
const res = await fetch("https://verimails.com/api/verify/single", {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify({ email })
});
if (!res.ok) throw new Error(`API error: ${res.status}`);
return res.json();
}
const result = await verifyEmail("user@example.com", "YOUR_API_KEY");
console.log(result.status); // "valid"
console.log(result.safe_to_send); // true
php
function verifyEmail($email, $apiKey) {
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "https://verimails.com/api/verify/single",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer {$apiKey}",
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => json_encode(["email" => $email])
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
return $result;
}
$result = verifyEmail("user@example.com", "YOUR_API_KEY");
if ($result["safe_to_send"]) {
echo "Safe to contact!";
}
狀態碼
| HTTP 狀態 | 說明 |
|---|---|
200 | 成功:已回傳結果 |
401 | 未經授權:缺少 API 金鑰或金鑰無效 |
422 | 驗證錯誤:電子郵件格式無效或缺少欄位 |
429 | 已超過速率限制:請放慢請求速度 |
500 | 伺服器錯誤:請稍後再試 |