根据指定的邮箱地址和操作类型,获取最新的验证码。支持多种操作类型如登录、修改密码、解锁等。
参数名 | 类型 | 必填 | 说明 | 示例值 |
---|---|---|---|---|
string | 是 | 邮箱地址 | user@example.com | |
operation | string | 是 | 操作类型:login(登录)、password(修改密码)、unlock(解锁)、2fa(2FA验证) | login |
max_time | string | 否 | 查询起始时间,格式:YYYY-MM-DD HH:MM:SS | 2025-06-26 11:47:36 |
refresh_token | string | 否 | 微软邮箱专用:Refresh Token | - |
access_token | string | 否 | 微软邮箱专用:Access Token | - |
获取指定邮箱的所有邮件列表,支持按时间筛选。返回邮件的完整信息包括发件人、主题、内容等。
参数名 | 类型 | 必填 | 说明 | 示例值 |
---|---|---|---|---|
string | 是 | 邮箱地址(仅支持自有域名邮箱) | user@example.com | |
max_time | string | 否 | 查询起始时间,格式:YYYY-MM-DD HH:MM:SS | 2025-06-26 11:47:36 |
# 获取登录验证码 curl -X POST "http://152.53.90.135:9000/api/v1/email/get-code" \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com", "operation": "login", "max_time": "2025-06-27 14:00:00" }' # 获取密码重置验证码 curl -X POST "http://152.53.90.135:9000/api/v1/email/get-code" \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com", "operation": "password", "max_time": "2025-06-27 14:00:00" }'
import requests import json url = "http://152.53.90.135:9001/api/v1/email/get-code" headers = { "Content-Type": "application/json" } # 获取登录验证码 login_data = { "email": "user@example.com", "operation": "login", "max_time": "2025-06-27 14:00:00" } response = requests.post(url, headers=headers, data=json.dumps(login_data)) result = response.json() if result.get("success"): print(f"验证码: {result.get('verify_code')}") print(f"邮件时间: {result.get('email_time')}") else: print(f"获取失败: {result.get('message')}") # 获取密码重置验证码 password_data = { "email": "user@example.com", "operation": "password", "max_time": "2025-06-27 14:00:00" } response = requests.post(url, headers=headers, data=json.dumps(password_data)) result = response.json() if result.get("success"): print(f"密码重置验证码: {result.get('verify_code')}") print(f"邮件时间: {result.get('email_time')}") else: print(f"获取失败: {result.get('message')}")
// 使用 fetch API async function getVerificationCode(operation = 'login') { const url = "http://152.53.90.135:9001/api/v1/email/get-code"; const data = { email: "user@example.com", operation: operation, max_time: "2025-06-27 14:00:00" }; try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }); const result = await response.json(); if (result.success) { console.log(`${operation}验证码: ${result.verify_code}`); console.log(`邮件时间: ${result.email_time}`); return result.verify_code; } else { console.log(`获取失败: ${result.message}`); return null; } } catch (error) { console.error('请求失败:', error); return null; } } // 获取登录验证码 getVerificationCode('login'); // 获取密码重置验证码 getVerificationCode('password'); // 获取解锁验证码 getVerificationCode('unlock');
using System; using System.Net.Http; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; public class EmailVerificationClient { private readonly HttpClient _httpClient; public EmailVerificationClient() { _httpClient = new HttpClient(); } public async TaskGetVerificationCodeAsync(string operation = "login") { var url = "http://152.53.90.135:9001/api/v1/email/get-code"; var data = new { email = "user@example.com", operation = operation, max_time = "2025-06-27 14:00:00" }; var json = JsonConvert.SerializeObject(data); var content = new StringContent(json, Encoding.UTF8, "application/json"); try { var response = await _httpClient.PostAsync(url, content); var responseContent = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject (responseContent); if (result.success == true) { Console.WriteLine($"{operation}验证码: {result.verify_code}"); Console.WriteLine($"邮件时间: {result.email_time}"); return result.verify_code; } else { Console.WriteLine($"获取失败: {result.message}"); return null; } } catch (Exception ex) { Console.WriteLine($"请求失败: {ex.Message}"); return null; } } // 使用示例 public async Task Example() { // 获取登录验证码 await GetVerificationCodeAsync("login"); // 获取密码重置验证码 await GetVerificationCodeAsync("password"); // 获取解锁验证码 await GetVerificationCodeAsync("unlock"); } }
# 获取所有邮件 curl -X POST "http://152.53.90.135:9001/api/v1/email/get-all" \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com" }' # 获取指定时间后的邮件 curl -X POST "http://152.53.90.135:9001/api/v1/email/get-all" \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com", "max_time": "2025-06-26 00:00:00" }'
import requests import json url = "http://152.53.90.135:9001/api/v1/email/get-all" headers = { "Content-Type": "application/json" } # 获取所有邮件 data = { "email": "user@example.com", "max_time": "2025-06-26 00:00:00" # 可选参数 } response = requests.post(url, headers=headers, data=json.dumps(data)) result = response.json() if result.get("success"): emails = result.get("emails", []) print(f"共获取到 {len(emails)} 封邮件:") for email in emails: print(f"ID: {email['id']}") print(f"发件人: {email['from']}") print(f"主题: {email['subject']}") print(f"时间: {email['createdAt']}") print(f"内容: {email['body'][:100]}...") print("-" * 50) else: print(f"获取失败: {result.get('message')}")
// 使用 fetch API async function getAllEmails() { const url = "http://152.53.90.135:9001/api/v1/email/get-all"; const data = { email: "user@example.com", max_time: "2025-06-26 00:00:00" // 可选参数 }; try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }); const result = await response.json(); if (result.success) { const emails = result.emails || []; console.log(`共获取到 ${emails.length} 封邮件:`); emails.forEach(email => { console.log(`ID: ${email.id}`); console.log(`发件人: ${email.from}`); console.log(`主题: ${email.subject}`); console.log(`时间: ${email.createdAt}`); console.log(`内容: ${email.body.substring(0, 100)}...`); console.log('-'.repeat(50)); }); return emails; } else { console.log(`获取失败: ${result.message}`); return []; } } catch (error) { console.error('请求失败:', error); return []; } } getAllEmails();
using System; using System.Collections.Generic; using System.Net.Http; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; public class EmailListClient { private readonly HttpClient _httpClient; public EmailListClient() { _httpClient = new HttpClient(); } public async Task> GetAllEmailsAsync() { var url = "http://152.53.90.135:9001/api/v1/email/get-all"; var data = new { email = "user@example.com", max_time = "2025-06-26 00:00:00" // 可选参数 }; var json = JsonConvert.SerializeObject(data); var content = new StringContent(json, Encoding.UTF8, "application/json"); try { var response = await _httpClient.PostAsync(url, content); var responseContent = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject
(responseContent); if (result.success == true) { var emails = JsonConvert.DeserializeObject >(result.emails.ToString()); Console.WriteLine($"共获取到 {emails.Count} 封邮件:"); foreach (var email in emails) { Console.WriteLine($"ID: {email.id}"); Console.WriteLine($"发件人: {email.from}"); Console.WriteLine($"主题: {email.subject}"); Console.WriteLine($"时间: {email.createdAt}"); Console.WriteLine($"内容: {email.body.ToString().Substring(0, Math.Min(100, email.body.ToString().Length))}..."); Console.WriteLine(new string('-', 50)); } return emails; } else { Console.WriteLine($"获取失败: {result.message}"); return new List
(); } } catch (Exception ex) { Console.WriteLine($"请求失败: {ex.Message}"); return new List (); } } }