InTouch Hub · Blue Isle Software

Mailgun

Send, route, and track transactional email and validate addresses via the Mailgun API.

Provided free and as is, without warranty of any kind — including merchantability, fitness for a particular purpose, and the accuracy or completeness of any result. See the licence. You are responsible for checking what this produces before relying on it.

emailmarketing-emailmessageroutesstatustrackervalidation

Mailgun

Send, route, and track transactional email and validate addresses via the Mailgun API.

This is a standard-library Python InTouch tool (no external packages). It talks to Mailgun over HTTPS using HTTP Basic authentication and returns the raw API response as a JSON string in result alongside the HTTP status.

What it does

Base URL & regions

Region Base URL
US (default) https://api.mailgun.net
EU https://api.eu.mailgun.net

Set region: eu if your domain is hosted in the EU; otherwise leave it blank (US). The region must match where your sending domain lives.

Authentication (apiKey)

Mailgun uses HTTP Basic auth with the username api and your API key as the password (the classic --user 'api:YOUR_API_KEY' curl idiom). The tool encodes this for you — just supply apiKey.

To get a key:

  1. Sign in to the Mailgun dashboard.
  2. Open API Keys.
  3. Use your account API key for full access (validation, events, routes), or create a Domain Sending Key for send-only access scoped to one domain.

credentialBased: false — the key is passed inline as the apiKey input.

Operations & endpoints

Operation Method & path
send-message POST /v3/{domain}/messages
validate-address GET /v4/address/validate?address=...
list-events GET /v3/{domain}/events
list-routes GET /v3/routes
create-route POST /v3/routes

Inputs

to may be comma-separated for multiple recipients. For create-route, supply multiple actions by separating them with || (e.g. forward('https://x/hook')||store()).

Examples

Send an email

{
  "apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "operation": "send-message",
  "domain": "mg.example.com",
  "from": "Excited User <[email protected]>",
  "to": "[email protected]",
  "subject": "Hello there!",
  "text": "Testing some Mailgun awesomeness!"
}

Validate an address

{
  "apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "operation": "validate-address",
  "address": "[email protected]"
}

List recent delivery events

{
  "apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "operation": "list-events",
  "domain": "mg.example.com",
  "event": "failed",
  "limit": "25"
}

Create an inbound route (forward to a webhook)

{
  "apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "operation": "create-route",
  "expression": "match_recipient('.*@mg.example.com')",
  "action": "forward('https://example.com/incoming')||stop()",
  "description": "Forward all inbound mail to our webhook",
  "priority": "1"
}

Output

Every call returns:

On a transport error the tool prints {"error": "..."} and exits non-zero so the job step is marked FAILED. HTTP 4xx/5xx responses are not treated as transport errors — Mailgun's error JSON is returned in result with the real status so you can branch on it.

Publishes

The keys a later task may reference as {{taskName.key}}. Referencing anything not listed here resolves to nothing at run time.

Input Properties

Every property this tool accepts, from its own tool.iml.

Property Type Required Default Description
apiKey string yes DEPRECATED — bind an API Key credential to the task with credentialName instead. A key pasted here is stored in the workflow definition in clear and appears in every export of it. Still honoured for workflows built before the change.
operation string yes One of: send-message, validate-address, list-events, list-routes, create-route
region string no Mailgun region: 'us' (default, api.mailgun.net) or 'eu' (api.eu.mailgun.net). Must match where your domain is hosted.
domain string no send-message / list-events: your Mailgun sending domain, e.g. mg.example.com.
from string no send-message: sender, e.g. 'Excited User postmaster@mg.example.com'.
to string no send-message: recipient address(es), comma-separated for multiple.
subject string no send-message: email subject line.
text string no send-message: plain-text body. Provide text and/or html.
html string no send-message: HTML body. Provide text and/or html.
address string no validate-address: the email address to validate (GET /v4/address/validate).
providerLookup string no validate-address: 'true' or 'false' — whether to perform a provider (mailbox) lookup. Optional.
event string no list-events: filter by event type, e.g. delivered, failed, opened, clicked. Optional.
limit string no list-events / list-routes: max number of items to return. Optional.
skip string no list-routes: number of routes to skip (pagination offset). Optional.
expression string no create-route: filter expression, e.g. match_recipient('.*@example.com').
action string no create-route: action(s) to take, e.g. forward('https://example.com/hook') or stop(). Use '||' to separate multiple actions.
description string no create-route: human-readable description of the route. Optional.
priority string no create-route: route priority (lower = evaluated first). Optional.
name string no Path parameter for the operations whose URL contains {name}.