BillionMail API Email Sending Function Guide
Function Overview
BillionMail API's email sending function provides a complete email delivery solution, supporting the following core features:
✉️ Template-based email sending
👤 Customizable sender information
📊 Comprehensive data tracking (open rate/click-through rate/bounce rate)
🔄 Unsubscription management
📈 Detailed sending statistics
API Key Management
Create an API Key
Email Sending API --> Create API
Click "Create API" and fill in relevant information (API name, Email template, Subject, IP whitelist, etc.). The system will automatically generate a unique API Key.
- Supports independent IP whitelist configuration for each API to enhance security.
Sending Email API
Send a Single Email
Request Information
Endpoint:
/api/batch_mail/api/send
Method:
POST
Authentication: Required
Request Headers
X-API-Key: YOUR_API_KEY
Content-Type: application/json
Request Body
{
"recipient": "[email protected]",
"addresser": "[email protected]"
}
Request Parameter Description
Parameter | Type | Required | Description |
---|---|---|---|
recipient | string | Yes | Recipient email address |
addresser | string | No | Custom sender email address |
Note: If the
addresser
parameter is not provided, the default sender email will be used.
Response Example
{
"success": true,
"code": 0,
"msg": "Email sent successfully",
"data": null
}
Usage Examples
CURL Example
# Send an email
curl -k -X POST 'https://your-domain.com/api/batch_mail/api/send' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"recipient": "[email protected]"
}'
Python Example
import requests
def send_email(api_key, recipient):
url = 'https://your-domain.com/api/batch_mail/api/send'
headers = {
'X-API-Key': api_key
}
data = {
'recipient': recipient
}
response = requests.post(url, headers=headers, json=data)
return response.json()
Error Code Explanation
Error Code | Description | Solution |
---|---|---|
1001 | Invalid API key | Check if the API key is correct |
1002 | IP not allowed | Check if the IP whitelist is set |
1003 | Invalid recipient | Check the email address format |
1004 | Template does not exist | Check the template ID |
1005 | Sending failed | View detailed error logs |
Feature Descriptions
IP Whitelist Function
Each API can be individually configured with an IP whitelist, allowing only specified IPs to call the API.
If no whitelist is set, all IPs can access the API.
Whitelist configuration is supported during API creation and update, and can be adjusted at any time.
Calls from non-whitelist IPs will return error code 1002.
Email Tracking Function
Open Tracking
Automatically records the number of email opens.
Counts the number of unique openers.
Provides data on open time distribution.
Link Tracking
Tracks clicks on links within emails.
Records clickers and timestamps.
Analyzes link click popularity.
Data Statistics
Updates statistics in real time.
Provides multi-dimensional analysis.
Unsubscription Management (Optional)
Unsubscription Link
Automatically adds an unsubscription link at the bottom of emails.
Supports one-click unsubscription.
Automatically updates unsubscription status.
Unsubscription List Management
- Maintains a global unsubscription list.
Sending Statistics
Provides statistics on the following dimensions:
Total number of emails sent
Delivery rate
Open rate
Click-through rate
Bounce rate
Unsubscription rate
Best Practices
Security Recommendations
API Key Management
Safeguard API keys properly.
Rotate API keys regularly.
Avoid key leaks.
Access Control
Use HTTPS for API calls.
Set up IP whitelists.
Monitor abnormal access.
Sending Optimization
Sending Strategy
Control sending frequency reasonably.
Avoid dense sending.
Pay attention to sending statistics.
Address Management
Clean up invalid addresses regularly.
Handle bounced emails promptly.
Maintain a blacklist.
Content Optimization
Template Management
Use variables for personalization.
Keep templates concise.
Update content regularly.
Performance Optimization
Conduct A/B testing.
Analyze statistical data.
Optimize sending time.
FAQs
1. Sending Issues
Q: How to handle emails that failed to send?
A: The system automatically records failed emails. You can view the failure reasons through the API management list in the dashboard.
2. Statistical Issues
Q: How to improve the delivery rate?
A: Maintain a good sending record, avoid sending spam, and clean up invalid addresses regularly.
3. Functional Issues
Q: How to view sending statistics?
A: Accessible through the API list in the dashboard.
4. Technical Issues
Q: Does it support batch sending?
A: The API currently only supports single email sending. For batch sending, use the task function.
5. Other Issues
Q: How to handle unsubscription requests?
A: The system automatically processes unsubscription requests and maintains the unsubscription list.