Compatible API · Mailgun

Mailgun API compatible: change the URL and the key

SMTP Senpai accepts send requests in the same format as the Mailgun Messages API. Point your code to SMTP Senpai, use your msp_ key and keep your SDK, your fields and your error handling.

14 days free · up to 100 emails a day · card required · if you don’t cancel within 14 days, the plan you chose starts

  • Same paths, fields and errors
  • Sending servers and log in the EU
  • 14-day free trial
Node.js · mailgun.js 14.1.0 · what changes
  import Mailgun from 'mailgun.js';
  import FormData from 'form-data';
  const mailgun = new Mailgun(FormData);
- const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
+ const mg = mailgun.client({
+   username: 'api',
+   key: process.env.SMTP_SENPAI_KEY, // msp_…
+   url: 'https://app.mailsenpai.com/relay/compat/mailgun',
+ });
what changes

Two things change, the rest stays

Same paths, same fields, same responses and error shapes as the Mailgun Messages API.

Base URLhttps://app.mailsenpai.com/relay/compat/mailgun
Or the dedicated hosthttps://mailgun-api.mailsenpai.com
Where the key goesBasic auth, user api, password msp_…
Paths (unchanged)POST /v3/{domain}/messages, /v3/{domain}/messages.mime

The sender must be on a domain verified in your SMTP Senpai area and signed with DKIM: otherwise the request is refused with an error in the Mailgun format. To try without sending, use o:testmode=yes: the request is checked and nothing leaves.

the code

Your code, pointed to SMTP Senpai

Node.js · mailgun.js 14.1.0 · after
import Mailgun from 'mailgun.js';
import FormData from 'form-data';
const mailgun = new Mailgun(FormData);
const mg = mailgun.client({
  username: 'api',
  key: process.env.SMTP_SENPAI_KEY, // msp_…
  url: 'https://app.mailsenpai.com/relay/compat/mailgun',
});

Tested with mailgun.js 14.1.0: run with the official SDK against the SMTP Senpai endpoints.

Other languages and frameworks

Settings read in the source code of each SDK: they follow the same rule (base URL or host, plus your key). Try them with a test send before going live.

SDKSettingStatus
PHP mailgun/mailgun-phpMailgun::create($key, 'https://mailgun-api.mailsenpai.com')Read in the SDK source code, not yet tested
Ruby mailgun-rubyMailgun::Client.new(key, 'app.mailsenpai.com/relay/compat/mailgun')Read in the SDK source code, not yet tested
Python mailgunClient(auth=('api', key), api_url='https://app.mailsenpai.com/relay/compat/mailgun')Read in the SDK source code, not yet tested
Laravel'mailgun' => ['domain' => 'yourdomain.com', 'secret' => KEY, 'endpoint' => 'mailgun-api.mailsenpai.com', 'scheme' => 'https']Read in the SDK source code, not yet tested
Symfony MailerMAILER_DSN=mailgun+api://KEY:[email protected]Read in the SDK source code, not yet tested
fields

What works, what is ignored, what is refused

Works

from, to (repeated or comma-separated), cc, bcc, subject, text, html, attachment, inline (cid:), h:

, recipient-variables (%recipient.x%), o:testmode; messages.mime (to + message)

Accepted without effect

o:tag, o:tracking*, other o: options, v: variables, amp-html

Named in the X-MailSenpai-Ignored response header.

Refused with the Mailgun error

template, t: options, o:deliverytime and the other scheduling options (400)

The domain in the path must be one of your sending domains verified in SMTP Senpai. Multipart and urlencoded bodies both work; repeated to fields and several attachments are kept.

events and webhooks

Delivery results from the SMTP Senpai API

The Mailgun endpoints for logs, events, statistics and webhooks are not reproduced. Results (sent, delivered, bounce, defer, complaint, dropped, open, click) come from the SMTP Senpai API with the same key: GET /relay/v1/eventi, or a signed webhook set in your SMTP Senpai area.

The id in the send response is the message_id of those events. Each response also carries X-MailSenpai-Result (sent, queued, suppressed, failed).

Read the events and webhook reference

Limits. Up to 50 recipients per message and 500 copies per request (over 50 they are queued and leave within about a minute), 10 attachments and 10 MB per message. Templates and scheduled sending are not supported: send the final content when you want it to leave.
Terminal · SMTP Senpai events
curl "https://app.mailsenpai.com/relay/v1/eventi?quanti=50" \
  -H "Authorization: Bearer $SMTP_SENPAI_KEY"

# {"ok": true, "eventi": [{"type": "delivered",
#   "email": "…", "message_id": "…", …}], "prossimo": …}

Frequently asked questions

Do I have to rewrite my Mailgun code?

No. You change the base URL (or the host) and the key. Paths, fields, responses and the error format stay those of the Mailgun Messages API, so your SDK and your error handling keep working.

What about templates and scheduled sending?

They are not supported: requests that use them are refused with the native error, so nothing leaves by mistake. Build the final content in your code and send it when you want it to leave.

How do I get bounces, opens and webhooks?

From the SMTP Senpai API, with the same key: GET /relay/v1/eventi or a signed webhook set in your SMTP Senpai area. The Mailgun event and webhook endpoints are not reproduced.

Can I test without sending?

Yes, as with Mailgun: set o:testmode=yes. The request is checked and nothing is sent.

Which domain goes in the path?

One of your sending domains verified in SMTP Senpai, as /v3/yourdomain.com/messages.

Try SMTP Senpai with your current code

14 days to change the base URL and the key, send your real emails and check every result in the log. Then decide.

Mailgun is a trademark of Mailgun Technologies, Inc., a Sinch group company. It is named only to describe the request format SMTP Senpai accepts. MailSenpai is not affiliated with Mailgun or Sinch and this page is not approved by them. Information checked on 9 October 2026.

14 days freeFree trial