API文档
了解如何使用金牛邮箱API服务发送邮件
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| api_key | string | 是 | 您的API密钥 |
| to | string | 是 | 收件人邮箱地址 |
| subject | string | 是 | 邮件主题 |
| content | string | 是 | 邮件内容(支持HTML) |
| is_html | boolean | 否 | 是否为HTML内容,默认为true |
响应说明
| 字段 | 类型 | 说明 |
|---|---|---|
| success | boolean | 请求是否成功 |
| message | string | 响应消息 |
| data | object | 响应数据(成功时返回) |
代码示例
cURL
JavaScript
PHP
Python
cURL
curl -X POST https://mail.jnqj.net/api/mail/send.php \
-H "Content-Type: application/json" \
-d '{
"api_key": "JNQJ-MailAPI-********************************",
"to": "recipient@example.com",
"subject": "测试邮件",
"content": "<h1>Hello World</h1><p>这是一封测试邮件</p>",
"is_html": true
}'
JavaScript
const sendEmail = async () => {
const response = await fetch('https://mail.jnqj.net/api/mail/send.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
api_key: 'JNQJ-MailAPI-********************************',
to: 'recipient@example.com',
subject: '测试邮件',
content: '<h1>Hello World</h1><p>这是一封测试邮件</p>',
is_html: true
})
});
const result = await response.json();
console.log(result);
};
sendEmail();
PHP
<?php
$data = [
'api_key' => 'JNQJ-MailAPI-********************************',
'to' => 'recipient@example.com',
'subject' => '测试邮件',
'content' => '<h1>Hello World</h1><p>这是一封测试邮件</p>',
'is_html' => true
];
$ch = curl_init('https://mail.jnqj.net/api/mail/send.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
Python
import requests
import json
url = 'https://mail.jnqj.net/api/mail/send.php'
data = {
'api_key': 'JNQJ-MailAPI-********************************',
'to': 'recipient@example.com',
'subject': '测试邮件',
'content': 'Hello World
这是一封测试邮件
',
'is_html': True
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, data=json.dumps(data), headers=headers)
result = response.json()
print(result)
错误码说明
| HTTP状态码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 400 | 请求参数错误 |
| 401 | API密钥无效或已过期 |
| 403 | 权限不足(未设置邮箱授权码) |
| 429 | 请求过于频繁 |
| 500 | 服务器内部错误 |