Documentation
MailBridge API Reference
Complete guide to integrating and using the MailBridge API
Getting Started
MailBridge is a powerful email infrastructure service that allows you to send emails using your own SMTP server through our secure API. Follow these steps to get started:
- Create a free account
- Configure your SMTP settings
- Generate an API key
- Start sending emails through our API
SMTP Configuration
Before you can send emails, you need to configure your SMTP server settings. Navigate to Dashboard > SMTP Settings and enter the following information:
| Field | Description | Example |
|---|---|---|
| SMTP Host | Your SMTP server hostname | smtp.gmail.com |
| SMTP Port | Port number (usually 587 for TLS) | 587 |
| Username | Your SMTP account username | user@example.com |
| Password | Your SMTP account password | •••••••• |
| From Name | Default sender name | My App |
| From Email | Default sender email | noreply@myapp.com |
For Gmail users: You'll need to use an App Password if 2FA is enabled.
API Keys
API keys are used to authenticate your requests. To generate an API key:
- Go to Dashboard > API Keys
- Click 'Generate API Key'
- Copy and securely store your API key
Never share your API key or commit it to version control. Keep it secure and rotate it periodically.
Sending Emails
Send emails using our REST API. Here's how to make requests:
cURL Example
curl -X POST http://localhost:5173/api/send-email \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"to": "recipient@example.com",
"subject": "Hello from MailBridge",
"text": "This is a test email.",
"html": "<p>This is a <strong>test</strong> email.</p>",
"cc": "cc@example.com",
"bcc": "bcc@example.com"
}'JavaScript Example
// Using fetch
const response = await fetch('http://localhost:5173/api/send-email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-api-key'
},
body: JSON.stringify({
to: 'recipient@example.com',
subject: 'Hello from MailBridge',
text: 'This is a test email.',
html: '<p>This is a <strong>test</strong> email.</p>',
cc: 'cc@example.com',
bcc: 'bcc@example.com'
})
});
const data = await response.json();
console.log(data);Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| to | string | Yes | Recipient email address |
| subject | string | Yes | Email subject line |
| text | string | No | Plain text version of the email |
| html | string | No | HTML version of the email |
| cc | string | No | CC recipients (comma-separated) |
| bcc | string | No | BCC recipients (comma-separated) |
| attachments | array | No | Array of attachment objects |
API Responses
Success Response
{
"success": true,
"message": "Email sent successfully",
"data": {
"id": "5f9d7a3b-8c1e-4b5a-9d7a-3b8c1e4b5a9d",
"recipient": "recipient@example.com",
"subject": "Hello from MailBridge",
"status": "success"
}
}Error Response
{
"success": false,
"message": "Failed to send email",
"error": "Invalid recipient email address"
}