Skip to content

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.
    alt text

Sending Email API

Send a Single Email

Request Information

  • Endpoint: /api/batch_mail/api/send

  • Method: POST

  • Authentication: Required

Request Headers

http
X-API-Key: YOUR_API_KEY  
Content-Type: application/json

Request Body

json
{
    "recipient": "[email protected]",  
    "addresser": "[email protected]"   
}

Request Parameter Description

ParameterTypeRequiredDescription
recipientstringYesRecipient email address
addresserstringNoCustom sender email address

Note: If the addresser parameter is not provided, the default sender email will be used.

Response Example

json
{
  "success": true,
  "code": 0,
  "msg": "Email sent successfully",
  "data": null
}

Usage Examples

CURL Example

bash
# 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

python
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 CodeDescriptionSolution
1001Invalid API keyCheck if the API key is correct
1002IP not allowedCheck if the IP whitelist is set
1003Invalid recipientCheck the email address format
1004Template does not existCheck the template ID
1005Sending failedView 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.

  • 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)

  • 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

  1. API Key Management

    • Safeguard API keys properly.

    • Rotate API keys regularly.

    • Avoid key leaks.

  2. Access Control

    • Use HTTPS for API calls.

    • Set up IP whitelists.

    • Monitor abnormal access.

Sending Optimization

  1. Sending Strategy

    • Control sending frequency reasonably.

    • Avoid dense sending.

    • Pay attention to sending statistics.

  2. Address Management

    • Clean up invalid addresses regularly.

    • Handle bounced emails promptly.

    • Maintain a blacklist.

Content Optimization

  1. Template Management

    • Use variables for personalization.

    • Keep templates concise.

    • Update content regularly.

  2. 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.

Released under the AGPLv3 License