📨 获取最新一封邮件
方法: GET 或 POST
URL: /api/mail-new
描述: 获取最新的一封邮件。如果邮件中含有 6 位数字验证码,会自动提取。
参数说明:
refresh_token(必填): 用于身份验证的 refresh_token。client_id(必填): 客户端 ID。email(必填): 邮箱地址。mailbox(必填): 邮箱文件夹,支持的值为INBOX或Junk。response_type(可选): 返回格式,支持的值为json或html,默认为json。password(可选): 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问。
使用示例:
JavaScript (Fetch API):
javascript
// GET 请求
fetch('https://yourdomain.com/api/mail-new?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com&mailbox=INBOX&response_type=json')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// POST 请求
fetch('https://yourdomain.com/api/mail-new', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
refresh_token: 'your_refresh_token',
client_id: 'your_client_id',
email: 'your_email@example.com',
mailbox: 'INBOX',
response_type: 'json'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));📂 获取全部邮件
方法: GET 或 POST
URL: /api/mail-all
描述: 获取全部邮件。如果邮件中含有 6 位数字验证码,会自动提取。
参数说明:
refresh_token(必填): 用于身份验证的 refresh_token。client_id(必填): 客户端 ID。email(必填): 邮箱地址。mailbox(必填): 邮箱文件夹,支持的值为INBOX或Junk。password(可选): 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问。
使用示例:
JavaScript (Fetch API):
javascript
// GET 请求
fetch('https://yourdomain.com/api/mail-all?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com&mailbox=INBOX')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// POST 请求
fetch('https://yourdomain.com/api/mail-all', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
refresh_token: 'your_refresh_token',
client_id: 'your_client_id',
email: 'your_email@example.com',
mailbox: 'INBOX'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));🗑️ 清空收件箱
方法: GET 或 POST
URL: /api/process-inbox
描述: 清空收件箱。
参数说明:
refresh_token(必填): 用于身份验证的 refresh_token。client_id(必填): 客户端 ID。email(必填): 邮箱地址。password(可选): 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问。
使用示例:
JavaScript (Fetch API):
javascript
// GET 请求
fetch('https://yourdomain.com/api/process-inbox?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// POST 请求
fetch('https://yourdomain.com/api/process-inbox', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
refresh_token: 'your_refresh_token',
client_id: 'your_client_id',
email: 'your_email@example.com'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));🗑️ 清空垃圾箱
方法: GET 或 POST
URL: /api/process-junk
描述: 清空垃圾箱。
参数说明:
refresh_token(必填): 用于身份验证的 refresh_token。client_id(必填): 客户端 ID。email(必填): 邮箱地址。password(可选): 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问。
使用示例:
JavaScript (Fetch API):
javascript
// GET 请求
fetch('https://yourdomain.com/api/process-junk?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// POST 请求
fetch('https://yourdomain.com/api/process-junk', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
refresh_token: 'your_refresh_token',
client_id: 'your_client_id',
email: 'your_email@example.com'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));📤 发送邮件
方法: GET 或 POST
URL: /api/send-mail
描述: 发送邮件。支持纯文本(text)或 HTML 格式(html)的内容。
参数说明:
refresh_token(必填): 用于身份验证的 refresh_token。client_id(必填): 客户端 ID。email(必填): 发件人邮箱地址。to(必填): 收件人邮箱地址。subject(必填): 邮件主题。text(可选): 邮件的纯文本内容(与html二选一)。html(可选): 邮件的 HTML 内容(与text二选一)。send_password(可选): 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 SEND_PASSWORD 来启用此功能。启用后,请求时需提供正确的 SEND_PASSWORD 参数方可访问。
使用示例:
JavaScript (Fetch API):
javascript
// GET 请求
fetch('https://yourdomain.com/api/send-mail?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com&to=recipient@example.com&subject=Hello&text=This is a test email')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
// POST 请求
fetch('https://yourdomain.com/api/send-mail', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
refresh_token: 'your_refresh_token',
client_id: 'your_client_id',
email: 'your_email@example.com',
to: 'recipient@example.com',
subject: 'Hello',
text: 'This is a test email', // 或者使用 html: '<p>This is a test email</p>'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));🔍 检测token信息
方法: GET 或 POST
URL: /api/token-info
描述: 检测refresh token类型和支持的功能,显示当前使用的认证方式(Graph API或IMAP)。
参数说明:
refresh_token(必填): 用于身份验证的 refresh_token。client_id(必填): 客户端 ID。email(可选): 邮箱地址。password(可选): 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问。
使用示例:
JavaScript (Fetch API):
javascript
// GET 请求
fetch('https://yourdomain.com/api/token-info?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));🗑️ 删除指定邮件
方法: GET 或 POST
URL: /api/delete-mail
描述: 根据邮件ID删除特定邮件,同时支持Graph API和IMAP模式。
参数说明:
refresh_token(必填): 用于身份验证的 refresh_token。client_id(必填): 客户端 ID。email(必填): 邮箱地址。message_id(必填): 要删除的邮件ID(可以是Graph API的ID或IMAP格式的ID)。confirm(必填): 删除确认,必须设置为YES才能执行删除操作。password(可选): 为增强接口安全性,防止滥用,现已支持密码验证功能。您可以通过在环境变量中配置 password 来启用此功能。启用后,请求时需提供正确的 password 参数方可访问。
使用示例:
JavaScript (Fetch API):
javascript
// GET 请求
fetch('https://yourdomain.com/api/delete-mail?refresh_token=your_refresh_token&client_id=your_client_id&email=your_email@example.com&message_id=message_id_here&confirm=YES')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));📋 功能改进说明
新增功能特性:
- 混合模式支持: 所有API端点现在都支持Graph API和IMAP两种模式,系统会自动检测并选择最佳模式。
- 完整邮件ID显示: 邮件获取API现在返回完整的Message-ID,便于邮件识别和操作。
- 增强的清空功能: 清空收件箱和垃圾箱功能现在支持IMAP模式,提供更好的兼容性。
- 智能删除功能: 新增的删除指定邮件API支持根据邮件ID精确删除,包含安全确认机制。
返回数据格式改进:
- 所有邮件数据现在包含
id、messageId、mode字段 - 清空和删除操作返回详细的统计信息和操作模式标识
- Token信息检测提供完整的权限分析和使用建议