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

ParameterTypeRequiredDescription
API Versionv3OptionalMatches Mailgun v3 URL structure.
Auth MethodHTTP BasicOptionalUsername: api, Password: your wemail API key.
Base URLURLOptionalhttps://api.wemail.io/bridge/mailgun

Supported Endpoints

ParameterTypeRequiredDescription
POST /v3/:domain/messagesSupportedOptionalfrom, 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.mimeSupportedOptionalA ready-made MIME message in message + the recipients in to; o:/h:/v: options as for /messages.
GET /v3/:domain/eventsSupportedOptionalEvents of messages sent from this domain. Filter by event, recipient/to, begin/end, limit, ascending; real paging.
GET /v3/domainsSupportedOptionalList all account domains.
GET /v3/domains/:domainSupportedOptionalDomain detail with DNS records.
GET/POST /v3/:domain/{bounces|unsubscribes|complaints}SupportedOptionalList (paged); add one address (form) or many (JSON array, up to 1,000).
GET/DELETE /v3/:domain/{bounces|unsubscribes|complaints}/:addressSupportedOptionalLook up or remove one address.
/v3/:domain/templates[/:name[/versions[/:tag]]]SupportedOptionalCreate, list, get, update, delete templates by Mailgun name; versions (one active version per template).
/v3/domains/:domain/webhooks[/:id]SupportedOptionalList, create, get, update, delete per-event webhook URLs for the domain.
GET /v5/accounts/http_signing_keySupportedOptionalThe key that signs every webhook the bridge set up (Mailgun signature scheme).

Mailgun v3 API Compatibility Matrix

ParameterTypeRequiredDescription
Messages — SendSupportedOptionalMultipart form-data, including attachments and inline images.
Messages — Send MIMESupportedOptionalPOST /:domain/messages.mime — the MIME is re-built by wemail (body, attachments, X- headers kept).
Messages — Stored MessagesNot SupportedOptional—
Events — QuerySupportedOptionalEvents of messages sent from the domain in the URL. Filter by event type, recipient, time range; ascending; paging.
Domains — ListSupportedOptionalReturns all account domains with DNS records.
Domains — Get DetailSupportedOptionalReturns domain object + sending DNS records.
Domains — Add/Delete/VerifyNot SupportedOptionalUse wemail console for domain management.
Domains — Connection/Tracking/DKIMNot SupportedOptional—
Suppressions — Bounces / Complaints / UnsubscribesSupportedOptionalList, 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 SupportedOptionalAnswers 501 — wemail has no inbound mail.
Mailing Lists (CRUD + Members)Not SupportedOptional—
Templates (CRUD + Versions)SupportedOptionalBy 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 SupportedOptional—
Tags (List/Get/Stats/Delete)Not SupportedOptionalTags can be set via o:tag but tag management not available.
IPs (List/Dedicated)Not SupportedOptional—
Email ValidationNot SupportedOptionalUse wemail /v3/validate endpoint instead.
Webhooks (CRUD)SupportedOptionalPer-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.
SubaccountsNot SupportedOptional—
Keys (CRUD)Not SupportedOptionalUse wemail console.
Credentials (SMTP)Not SupportedOptional—

Field-Level Compatibility

Detailed breakdown of every request field and response field across all supported endpoints.

POST /:domain/messages — Request Fields

ParameterTypeRequiredDescription
fromSupportedRequiredSender address. RFC 5322 format accepted (Name <email>).
toSupportedRequiredComma-separated recipients.
ccSupportedOptionalComma-separated CC recipients.
bccSupportedOptionalComma-separated BCC recipients.
subjectSupportedOptionalRequired unless template is set.
textSupportedOptionalPlain-text body.
htmlSupportedOptionalHTML body.
templateSupportedOptionalTemplate 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:tagSupportedOptionalTags (max 10). Multiple o:tag fields allowed.
o:trackingSupportedOptionalyes/no — enable/disable all tracking.
o:tracking-opensSupportedOptionalyes/no — open tracking.
o:tracking-clicksSupportedOptionalyes/no/htmlonly — click tracking.
o:deliverytimeSupportedOptionalRFC 2822 date for scheduled delivery.
o:testmodeSupportedOptionalyes — send in test mode.
o:sending-ip-poolIgnoredOptionalwemail chooses the sending IPs for every message; the field is accepted and ignored.
h:X-HeaderSupportedOptionalCustom headers via h: prefix (X-* headers are delivered). h:Reply-To sets the reply-to address; h:X-Mailgun-Variables supplies template variables.
v:variableSupportedOptionalCustom variables via v: prefix. Stored as metadata.
recipient-variablesSupportedOptionalJSON 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:variablesSupportedOptionalTemplate variables as a JSON object ({{key}} in the template).
attachmentSupportedOptionalFiles are delivered as attachments. Limits: 5 MB per file, 20 MB per message.
inlineSupportedOptionalInline images, referenced from the HTML as cid:<filename> (as in Mailgun).
o:dkimNot SupportedOptionalIgnored. DKIM handled by wemail.
o:require-tlsSupportedOptionalyes = 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-verificationNot SupportedOptionalIgnored.
o:time-zone-localizeNot SupportedOptionalIgnored.

POST /:domain/messages — Response

ParameterTypeRequiredDescription
idSupportedOptional<message-id@domain> format.
messageSupportedOptional"Queued. Thank you." on success.

GET /:domain/events — Request & Response

ParameterTypeRequiredDescription
event (query)SupportedOptionalFilter: delivered, failed, opened, clicked, complained, accepted, rejected, unsubscribed.
recipient / to (query)SupportedOptionalFilter by recipient email.
begin (query)SupportedOptionalUnix timestamp start.
end (query)SupportedOptionalUnix timestamp end.
limit (query)SupportedOptionalMax 300.
from / subject / message-id / tags (query)Not SupportedOptionalAccepted but ignored.
ascending (query)SupportedOptionalyes = oldest first.
Response: items[].eventSupportedOptionalMapped event type name.
Response: items[].timestampSupportedOptionalUnix timestamp.
Response: items[].recipientSupportedOptionalRecipient email.
Response: items[].envelopeSupportedOptionalsender, targets, transport.
Response: items[].message.headersSupportedOptionalto, from, subject, message-id.
Response: items[].tagsSupportedOptionalMessage tags array.
Response: items[].user-variablesSupportedOptionalCustom variables from v: fields.
Response: items[].delivery-statusSupportedOptionalOn 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[].geolocationSupportedOptionalOn open/click/unsubscribe: country, region, city.
Response: items[].client-infoSupportedOptionalOn open/click: client-name, client-os, device-type.
Response: pagingSupportedOptionalnext continues after the last item of the page (same filters); page until items is empty.

GET /domains & GET /domains/:domain

ParameterTypeRequiredDescription
Response: nameSupportedOptionalDomain name.
Response: stateSupportedOptionalactive or unverified.
Response: typeHardcodedOptionalAlways custom.
Response: created_atSupportedOptionalUTC date string.
Response: smtp_loginSupportedOptionalpostmaster@domain.
Response: sending_dns_recordsSupportedOptionalTXT/CNAME records with valid/invalid status.
Response: receiving_dns_recordsHardcodedOptionalAlways empty array.
Response: require_tlsHardcodedOptionalAlways false.
Response: wildcardHardcodedOptionalAlways false.

GET /:domain/bounces, complaints, unsubscribes

ParameterTypeRequiredDescription
limit (query)SupportedOptionalMax results per request.
Response: items[].addressSupportedOptionalSuppressed email address.
Response: items[].created_atSupportedOptionalUTC date string.
Response: items[].code (bounces)HardcodedOptionalAlways 550. Actual SMTP code not preserved.
Response: items[].error (bounces)SupportedOptionalBounce reason text.
Response: items[].tags (unsubscribes)HardcodedOptionalAlways ["*"].
Response: pagingSupportedOptionalnext continues after the last item; page until items is empty.
ScopeAccount-wideOptionalwemail 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.

LanguagePackageInstallRegistry
Node.jsmailgun.jsnpm
PythonrequestsPyPI
PHPmailgun/mailgun-phpPackagist
Rubymailgun-rubyRubyGems
Gomailgun-goGitHub
Javamailgun-javaMaven
C#RestSharpNuGet

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
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>"
Node.js
// 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." }
Python
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
<?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>',
]);
Ruby
# 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>'
})
Go
// 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)
}
Java
// 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());
    }
}
C#
// 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);
Response
{
  "id": "<msg-id@yourdomain.com>",
  "message": "Queued. Thank you."
}