Mailgun Bridge
Drop-in replacement for the Mailgun v3 API — authenticate with HTTP Basic using your wemail API key, keep your existing request structure.
The Mailgun bridge lets you migrate from Mailgun to wemail without changing your integration code. Point your base URL to https://api.wemail.io/bridge/mailgun, use HTTP Basic authentication with api as the username and your wemail API key as the password, and keep the same multipart form-data requests. The bridge translates every call into the wemail pipeline.
API Version & Authentication
| Parameter | Type | Required | Description |
|---|---|---|---|
API Version | v3 | Optional | Matches Mailgun v3 URL structure. |
Auth Method | HTTP Basic | Optional | Username: api, Password: your wemail API key. |
Base URL | URL | Optional | https://api.wemail.io/bridge/mailgun |
Supported Endpoints
| Parameter | Type | Required | Description |
|---|---|---|---|
POST /v3/:domain/messages | Supported | Optional | from, to, cc, bcc, subject, text, html, attachment, inline, template (by name), o:tag, o:tracking, o:deliverytime, o:testmode, h: headers (incl. Reply-To, X-Mailgun-Variables), v: variables, recipient-variables, t:variables. |
POST /v3/:domain/messages.mime | Supported | Optional | A ready-made MIME message in message + the recipients in to; o:/h:/v: options as for /messages. |
GET /v3/:domain/events | Supported | Optional | Events of messages sent from this domain. Filter by event, recipient/to, begin/end, limit, ascending; real paging. |
GET /v3/domains | Supported | Optional | List all account domains. |
GET /v3/domains/:domain | Supported | Optional | Domain detail with DNS records. |
GET/POST /v3/:domain/{bounces|unsubscribes|complaints} | Supported | Optional | List (paged); add one address (form) or many (JSON array, up to 1,000). |
GET/DELETE /v3/:domain/{bounces|unsubscribes|complaints}/:address | Supported | Optional | Look up or remove one address. |
/v3/:domain/templates[/:name[/versions[/:tag]]] | Supported | Optional | Create, list, get, update, delete templates by Mailgun name; versions (one active version per template). |
/v3/domains/:domain/webhooks[/:id] | Supported | Optional | List, create, get, update, delete per-event webhook URLs for the domain. |
GET /v5/accounts/http_signing_key | Supported | Optional | The key that signs every webhook the bridge set up (Mailgun signature scheme). |
Mailgun v3 API Compatibility Matrix
| Parameter | Type | Required | Description |
|---|---|---|---|
Messages — Send | Supported | Optional | Multipart form-data, including attachments and inline images. |
Messages — Send MIME | Supported | Optional | POST /:domain/messages.mime — the MIME is re-built by wemail (body, attachments, X- headers kept). |
Messages — Stored Messages | Not Supported | Optional | — |
Events — Query | Supported | Optional | Events of messages sent from the domain in the URL. Filter by event type, recipient, time range; ascending; paging. |
Domains — List | Supported | Optional | Returns all account domains with DNS records. |
Domains — Get Detail | Supported | Optional | Returns domain object + sending DNS records. |
Domains — Add/Delete/Verify | Not Supported | Optional | Use wemail console for domain management. |
Domains — Connection/Tracking/DKIM | Not Supported | Optional | — |
Suppressions — Bounces / Complaints / Unsubscribes | Supported | Optional | List, get, add (single or bulk JSON), delete one address. Clearing a whole list is refused (suppressions are account-wide) — use the console. |
Routes (Inbound Routing) | Not Supported | Optional | Answers 501 — wemail has no inbound mail. |
Mailing Lists (CRUD + Members) | Not Supported | Optional | — |
Templates (CRUD + Versions) | Supported | Optional | By Mailgun name per domain. wemail keeps ONE version per template — the active one, tagged v<n>; a new version replaces it. Handlebars: {{variable}} substitution (no block helpers). |
Stats (Domain/Aggregates) | Not Supported | Optional | — |
Tags (List/Get/Stats/Delete) | Not Supported | Optional | Tags can be set via o:tag but tag management not available. |
IPs (List/Dedicated) | Not Supported | Optional | — |
Email Validation | Not Supported | Optional | Use wemail /v3/validate endpoint instead. |
Webhooks (CRUD) | Supported | Optional | Per-domain, per-event URLs (max 3), stored as wemail webhook endpoints scoped to the domain. Payloads use Mailgun's format and signature; the signing key is at GET /v5/accounts/http_signing_key. |
Subaccounts | Not Supported | Optional | — |
Keys (CRUD) | Not Supported | Optional | Use wemail console. |
Credentials (SMTP) | Not Supported | Optional | — |
Field-Level Compatibility
Detailed breakdown of every request field and response field across all supported endpoints.
POST /:domain/messages — Request Fields
| Parameter | Type | Required | Description |
|---|---|---|---|
from | Supported | Required | Sender address. RFC 5322 format accepted (Name <email>). |
to | Supported | Required | Comma-separated recipients. |
cc | Supported | Optional | Comma-separated CC recipients. |
bcc | Supported | Optional | Comma-separated BCC recipients. |
subject | Supported | Optional | Required unless template is set. |
text | Supported | Optional | Plain-text body. |
html | Supported | Optional | HTML body. |
template | Supported | Optional | Template NAME as in Mailgun (resolved per sending domain for templates imported from Mailgun), or a wemail tpl_… id. The active version is used; t:version is ignored. |
o:tag | Supported | Optional | Tags (max 10). Multiple o:tag fields allowed. |
o:tracking | Supported | Optional | yes/no — enable/disable all tracking. |
o:tracking-opens | Supported | Optional | yes/no — open tracking. |
o:tracking-clicks | Supported | Optional | yes/no/htmlonly — click tracking. |
o:deliverytime | Supported | Optional | RFC 2822 date for scheduled delivery. |
o:testmode | Supported | Optional | yes — send in test mode. |
o:sending-ip-pool | Ignored | Optional | wemail chooses the sending IPs for every message; the field is accepted and ignored. |
h:X-Header | Supported | Optional | Custom headers via h: prefix (X-* headers are delivered). h:Reply-To sets the reply-to address; h:X-Mailgun-Variables supplies template variables. |
v:variable | Supported | Optional | Custom variables via v: prefix. Stored as metadata. |
recipient-variables | Supported | Optional | JSON object keyed by recipient address. Each to recipient gets an individual message with %recipient.key% filled in (values are HTML-escaped in the HTML body). Can't be combined with cc/bcc. |
t:variables | Supported | Optional | Template variables as a JSON object ({{key}} in the template). |
attachment | Supported | Optional | Files are delivered as attachments. Limits: 5 MB per file, 20 MB per message. |
inline | Supported | Optional | Inline images, referenced from the HTML as cid:<filename> (as in Mailgun). |
o:dkim | Not Supported | Optional | Ignored. DKIM handled by wemail. |
o:require-tls | Supported | Optional | yes = deliver only over TLS with a valid certificate; if the receiving server can't, the message is not delivered (you get a bounce or failed event) instead of going in clear text. o:skip-verification is not supported (the certificate is always verified). |
o:skip-verification | Not Supported | Optional | Ignored. |
o:time-zone-localize | Not Supported | Optional | Ignored. |
POST /:domain/messages — Response
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Supported | Optional | <message-id@domain> format. |
message | Supported | Optional | "Queued. Thank you." on success. |
GET /:domain/events — Request & Response
| Parameter | Type | Required | Description |
|---|---|---|---|
event (query) | Supported | Optional | Filter: delivered, failed, opened, clicked, complained, accepted, rejected, unsubscribed. |
recipient / to (query) | Supported | Optional | Filter by recipient email. |
begin (query) | Supported | Optional | Unix timestamp start. |
end (query) | Supported | Optional | Unix timestamp end. |
limit (query) | Supported | Optional | Max 300. |
from / subject / message-id / tags (query) | Not Supported | Optional | Accepted but ignored. |
ascending (query) | Supported | Optional | yes = oldest first. |
Response: items[].event | Supported | Optional | Mapped event type name. |
Response: items[].timestamp | Supported | Optional | Unix timestamp. |
Response: items[].recipient | Supported | Optional | Recipient email. |
Response: items[].envelope | Supported | Optional | sender, targets, transport. |
Response: items[].message.headers | Supported | Optional | to, from, subject, message-id. |
Response: items[].tags | Supported | Optional | Message tags array. |
Response: items[].user-variables | Supported | Optional | Custom variables from v: fields. |
Response: items[].delivery-status | Supported | Optional | On delivered/failed events: the receiving server's real SMTP code and reply, the enhanced status code, and its IP in mx-host. tls is not reported. |
Response: items[].geolocation | Supported | Optional | On open/click/unsubscribe: country, region, city. |
Response: items[].client-info | Supported | Optional | On open/click: client-name, client-os, device-type. |
Response: paging | Supported | Optional | next continues after the last item of the page (same filters); page until items is empty. |
GET /domains & GET /domains/:domain
| Parameter | Type | Required | Description |
|---|---|---|---|
Response: name | Supported | Optional | Domain name. |
Response: state | Supported | Optional | active or unverified. |
Response: type | Hardcoded | Optional | Always custom. |
Response: created_at | Supported | Optional | UTC date string. |
Response: smtp_login | Supported | Optional | postmaster@domain. |
Response: sending_dns_records | Supported | Optional | TXT/CNAME records with valid/invalid status. |
Response: receiving_dns_records | Hardcoded | Optional | Always empty array. |
Response: require_tls | Hardcoded | Optional | Always false. |
Response: wildcard | Hardcoded | Optional | Always false. |
GET /:domain/bounces, complaints, unsubscribes
| Parameter | Type | Required | Description |
|---|---|---|---|
limit (query) | Supported | Optional | Max results per request. |
Response: items[].address | Supported | Optional | Suppressed email address. |
Response: items[].created_at | Supported | Optional | UTC date string. |
Response: items[].code (bounces) | Hardcoded | Optional | Always 550. Actual SMTP code not preserved. |
Response: items[].error (bounces) | Supported | Optional | Bounce reason text. |
Response: items[].tags (unsubscribes) | Hardcoded | Optional | Always ["*"]. |
Response: paging | Supported | Optional | next continues after the last item; page until items is empty. |
Scope | Account-wide | Optional | wemail suppressions apply to every sending domain of the account, so each domain lists the account's suppressions. |
SDK Downloads
Download the official Mailgun SDK pre-configured for the wemail bridge. The base URL is already set to https://api.wemail.io/bridge/mailgun — just unzip and use with your wemail API key. Auth uses api as the username and your wemail API key as the password.
| Language | Package | Install | Registry |
|---|---|---|---|
| Node.js | mailgun.js | | npm |
| Python | requests | | PyPI |
| PHP | mailgun/mailgun-php | | Packagist |
| Ruby | mailgun-ruby | | RubyGems |
| Go | mailgun-go | | GitHub |
| Java | mailgun-java | | Maven |
| C# | RestSharp | | NuGet |
Known Deviations from Mailgun API
Bounce list code — The code on the bounces list is always 550; the real SMTP reply of each bounce is on its failed event (delivery-status).
Auto-creation — The bridge account is automatically created on the first authenticated request. No setup step is required.
API key permissions — The key's scope applies on the bridge as on the wemail API: a read-only key can only read, a send-only key can send and read, and changing suppressions, templates or webhooks needs a full-access key (403 otherwise).
Unsupported endpoints — Anything the bridge doesn't implement answers a Mailgun-style 404 { "message": "Not supported by the wemail Mailgun bridge: …" }, so your code sees a clear error instead of a silent success.
Request formats — Forms are accepted as multipart/form-data (needed for attachments) or application/x-www-form-urlencoded, exactly like Mailgun.
Migrating for good? Follow the Mailgun migration guide — templates and suppressions auto-import, and Mailgun stays warm for 30 days.
Code examples
curl -X POST https://api.wemail.io/bridge/mailgun/v3/yourdomain.com/messages \
-u "api:afn_live_YOUR_KEY" \
-F from="sender@yourdomain.com" \
-F to="user@example.com" \
-F subject="Hello from wemail" \
-F html="<p>Hello World</p>"// Official SDK: npm i mailgun.js form-data
const formData = require('form-data');
const Mailgun = require('mailgun.js');
const mailgun = new Mailgun(formData);
// Point the official Mailgun SDK at the wemail bridge
const mg = mailgun.client({
username: 'api',
key: 'afn_live_YOUR_KEY',
url: 'https://api.wemail.io/bridge/mailgun',
});
const res = await mg.messages.create('yourdomain.com', {
from: 'Sender <sender@yourdomain.com>',
to: ['user@example.com'],
subject: 'Hello from wemail',
html: '<p>Hello World</p>',
});
console.log(res); // { id, message: "Queued. Thank you." }import requests
response = requests.post(
"https://api.wemail.io/bridge/mailgun/v3/yourdomain.com/messages",
auth=("api", "afn_live_YOUR_KEY"),
data={
"from": "sender@yourdomain.com",
"to": "user@example.com",
"subject": "Hello from wemail",
"html": "<p>Hello World</p>",
},
)
print(response.json())
# {"id": "<msg-id@yourdomain.com>", "message": "Queued. Thank you."}<?php
// Official SDK: composer require mailgun/mailgun-php
use Mailgun\Mailgun;
// Point the official Mailgun SDK at the wemail bridge
$mg = Mailgun::create('afn_live_YOUR_KEY', 'https://api.wemail.io/bridge/mailgun');
$mg->messages()->send('yourdomain.com', [
'from' => 'Sender <sender@yourdomain.com>',
'to' => 'user@example.com',
'subject' => 'Hello from wemail',
'html' => '<p>Hello World</p>',
]);# Official SDK: gem install mailgun-ruby
require 'mailgun-ruby'
# Point the official Mailgun SDK at the wemail bridge
mg = Mailgun::Client.new('afn_live_YOUR_KEY', 'api.wemail.io/bridge/mailgun')
mg.send_message('yourdomain.com', {
from: 'Sender <sender@yourdomain.com>',
to: 'user@example.com',
subject: 'Hello from wemail',
html: '<p>Hello World</p>'
})// Official SDK: go get github.com/mailgun/mailgun-go/v4
package main
import (
"context"
"fmt"
"github.com/mailgun/mailgun-go/v4"
)
func main() {
mg := mailgun.NewMailgun("yourdomain.com", "afn_live_YOUR_KEY")
// Point the official Mailgun SDK at the wemail bridge
mg.SetAPIBase("https://api.wemail.io/bridge/mailgun/v3")
m := mg.NewMessage(
"Sender <sender@yourdomain.com>",
"Hello from wemail",
"", // plain-text body
"user@example.com",
)
m.SetHtml("<p>Hello World</p>")
_, id, err := mg.Send(context.Background(), m)
if err != nil {
panic(err)
}
fmt.Println(id)
}// Official SDK: com.mailgun:mailgun-java
import com.mailgun.api.v3.MailgunMessagesApi;
import com.mailgun.client.MailgunClient;
import com.mailgun.model.message.Message;
import com.mailgun.model.message.MessageResponse;
public class MailgunBridge {
public static void main(String[] args) {
// Point the official Mailgun SDK at the wemail bridge
MailgunMessagesApi api = MailgunClient
.config("https://api.wemail.io/bridge/mailgun", "afn_live_YOUR_KEY")
.createApi(MailgunMessagesApi.class);
Message message = Message.builder()
.from("Sender <sender@yourdomain.com>")
.to("user@example.com")
.subject("Hello from wemail")
.html("<p>Hello World</p>")
.build();
MessageResponse response = api.sendMessage("yourdomain.com", message);
System.out.println(response.getId());
}
}// Mailgun's documented C# uses RestSharp: dotnet add package RestSharp
using RestSharp;
using RestSharp.Authenticators;
// Point at the wemail bridge
var client = new RestClient("https://api.wemail.io/bridge/mailgun/v3")
{
Authenticator = new HttpBasicAuthenticator("api", "afn_live_YOUR_KEY")
};
var request = new RestRequest("yourdomain.com/messages", Method.Post);
request.AddParameter("from", "Sender <sender@yourdomain.com>");
request.AddParameter("to", "user@example.com");
request.AddParameter("subject", "Hello from wemail");
request.AddParameter("html", "<p>Hello World</p>");
var response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);{
"id": "<msg-id@yourdomain.com>",
"message": "Queued. Thank you."
}