Who it is for and what you gain
- You use Mailgun for transactional email or broadcasts to consent-based lists and want to keep your code and your webhooks.
- You want your data and your sending in the European Union, under a GDPR data processing agreement, without depending on picking the right account region.
- You want to pay less for the same: compare the prices in the table below.
Steps
- Create your account and verify your domain. In the dashboard, under Domains, the assistant gives you the DKIM, SPF (MAIL FROM) and DMARC records and checks they are published. They can live alongside Mailgun's: they do not clash. New accounts are reviewed before they can send.
- Create an API key for that domain (one per application: if one is compromised, you revoke only that one).
- Create the webhook in Mailgun format, under Webhooks, with your current receiver's URL. The Test button sends you a sample event.
- Change the base URL (or the SMTP host) and the key in your application. That is all: the rest of the code stays as it is.
- Send a test and look at it in the dashboard, with its delivery. When everything is fine, retire your Mailgun key.
Code before and after
With Mailgun's official library for each language. The highlighted lines are the ones that change.
Node.js · mailgun.js
const formData = require("form-data");
const Mailgun = require("mailgun.js");
const mg = new Mailgun(formData).client({
username: "api",
key: process.env.MAILGUN_API_KEY,
});
await mg.messages.create("acme.example", {
from: "Acme <hello@acme.example>",
to: ["lucia@example.com"],
subject: "Your order is on its way",
html: "<p>Hi Lucía, your order has shipped.</p>",
});const formData = require("form-data");
const Mailgun = require("mailgun.js");
const mg = new Mailgun(formData).client({
username: "api",
key: process.env.HERMAILY_API_KEY, url: "https://api.hermaily.com",});
await mg.messages.create("acme.example", {
from: "Acme <hello@acme.example>",
to: ["lucia@example.com"],
subject: "Your order is on its way",
html: "<p>Hi Lucía, your order has shipped.</p>",
});PHP · mailgun/mailgun-php
use Mailgun\Mailgun;
$mg = Mailgun::create(getenv('MAILGUN_API_KEY'));
$mg->messages()->send('acme.example', [
'from' => 'Acme <hello@acme.example>',
'to' => 'lucia@example.com',
'subject' => 'Your order is on its way',
'html' => '<p>Hi Lucía, your order has shipped.</p>',
]);use Mailgun\Mailgun;
$mg = Mailgun::create(getenv('HERMAILY_API_KEY'), 'https://api.hermaily.com');$mg->messages()->send('acme.example', [
'from' => 'Acme <hello@acme.example>',
'to' => 'lucia@example.com',
'subject' => 'Your order is on its way',
'html' => '<p>Hi Lucía, your order has shipped.</p>',
]);Python · mailgun
import os
from mailgun.client import Client
client = Client(auth=("api", os.environ["MAILGUN_API_KEY"]))
client.messages.create(domain="acme.example", data={
"from": "Acme <hello@acme.example>",
"to": "lucia@example.com",
"subject": "Your order is on its way",
"html": "<p>Hi Lucía, your order has shipped.</p>",
})import os
from mailgun.client import Client
client = Client(auth=("api", os.environ["HERMAILY_API_KEY"]), api_url="https://api.hermaily.com")client.messages.create(domain="acme.example", data={
"from": "Acme <hello@acme.example>",
"to": "lucia@example.com",
"subject": "Your order is on its way",
"html": "<p>Hi Lucía, your order has shipped.</p>",
})Over SMTP
If you send over SMTP (a CMS, an ERP, an application that does not speak HTTP), the change is even shorter:
| Mailgun | Hermaily | |
|---|---|---|
| Host | smtp.mailgun.org | smtp.hermaily.com |
| Port | Whichever you use | 587 (STARTTLS) or 465 (TLS) |
| Username | postmaster@your-domain | apikey (any value works) |
| Password | Your Mailgun key | Your Hermaily API key |
For the broadcast stream, add the header X-Hermaily-Stream: broadcast. More details in the SMTP documentation.
Equivalents
POST /v3/{domain}/messages
The base URL goes from https://api.mailgun.net to https://api.hermaily.com. Unrecognized fields are ignored without an error, so also check what is not supported.
| Mailgun | In Hermaily |
|---|---|
Basic api:key | Your Hermaily API key as the password. |
{domain} | Ignored: the sender is checked against your account's verified domains. |
from, to, cc, bcc, subject, text, html | Same (form or multipart; to can repeat). |
attachment, inline | multipart files; inline files are referenced by their file name. |
o:tag | Repeat it for several tags: all of them are kept (up to 10). |
o:tracking, o:tracking-opens, o:tracking-clicks | Open and click tracking. |
h:* | Headers; h:Reply-To is the reply address. |
v:*, h:X-Mailgun-Variables | Metadata; in webhooks it arrives in user-variables. |
h:X-Hermaily-Stream | broadcast for the broadcast stream. |
| Response | {"id": "<…@hermaily>", "message": "Queued. Thank you."} |
Webhook events
With the webhook in Mailgun format, each Hermaily event arrives with the name Mailgun uses:
| Hermaily | What happened | Mailgun format |
|---|---|---|
send | Left for the recipient's server | accepted |
delivery | Delivered | delivered |
delivery_delay | Temporary delay | failed (temporary) |
bounce | Bounce | Permanent: failed (permanent); temporary: failed (temporary) |
complaint | Spam complaint | complained |
reject | Rejected before sending | rejected |
rendering_failure | Rendering failure | rejected |
open | Open | opened |
click | Click | clicked |
unsubscribe | Unsubscribe | unsubscribed |
In Mailgun format the signature is in the body, as in Mailgun: signature.signature = HMAC-SHA256(secret, timestamp + token) in hex. Your verification code still works: only the key changes, which is the Hermaily webhook secret. The request also carries X-Hermaily-Signature.
The full reference, with every field, is in the documentation: migrating from Mailgun.
What is not supported
Hermaily emulates Mailgun's sending, not its whole API. This is what you will not find:
- Templates (
template,t:variables): ignored. Send the finished HTML. - Scheduled delivery (
o:deliverytime): ignored, and the message goes out right away. - Test mode (
o:testmode): ignored, so the message is really sent. - Batch sending with
recipient-variables: it is not split into one message per recipient and%recipient.…%is not replaced. Everytowould go in the same message and see each other: to send to many people, make one request per recipient or use the native API's batch sending. - Sending ready-made MIME (
/v3/{domain}/messages.mime): it does not exist. Use SMTP for that. - The rest of the API (events, stats, routes, lists, address validation, domains): it does not exist here. Suppressions, stats and lists are managed in the dashboard.
What it costs compared with Mailgun
Monthly cost of both services at the most common volumes:
| Emails a month | Hermaily | Plan Hermaily | Mailgun |
|---|---|---|---|
| 10,000 | $6 (€5) | Starter | $15 |
| 50,000 | $19.50 (€17) | Growth | $35 |
| 100,000 | $33.50 (€29) | Business | $75 |
| 250,000 | $79 (€69) | Pro | $215 |
Prices before tax. Hermaily: the cheapest plan that covers the volume, counting overage, with messages of up to 50 kB on average. Mailgun: prices checked on 26 November 2026 on its pricing page, cheapest monthly plan with no annual commitment that covers the volume. More providers and volumes in Pricing.
Not sure yet whether to switch? See Hermaily as a Mailgun alternative: why people switch and when Mailgun is still the better choice.
Frequently asked questions
Do I have to change my code to migrate from Mailgun?
No. Keep Mailgun's library and change only the base URL (or the SMTP host) and the API key. Hermaily answers in Mailgun's shape.
Does my Mailgun webhook verification code still work?
Yes. In Mailgun format the signature is in the body and is computed the same way (HMAC-SHA256 of timestamp plus token); only the key changes, which is the webhook secret in Hermaily.
What about the domain in the URL, /v3/{domain}/messages?
It is ignored. Hermaily checks the sender against your account's verified domains, so you do not need to change that part of the URL.
Can I use SMTP instead of the API?
Yes. Replace smtp.mailgun.org with smtp.hermaily.com (port 587 with STARTTLS or 465 with TLS); the username can be anything (we recommend apikey) and the password is your Hermaily key.
Does batch sending with recipient-variables work?
No. Hermaily does not split a send into one message per recipient: make one request per recipient or use the native API's batch sending.
Can I migrate gradually?
Yes. Since the code is the same, you can send part of your traffic through Hermaily and the rest through Mailgun until you are confident.
Try Hermaily with your Mailgun code
Create the account, verify your domain and send your first email with the library you already have. The Free plan includes 300 emails a month.