← 返回 Skills 市场
byungkyu

Mailgun

作者 byungkyu · GitHub ↗ · v1.0.0
cross-platform ✓ 安全检测通过
766
总下载
3
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install mailgun-api
功能描述
Mailgun API integration with managed OAuth. Transactional email service for sending, receiving, and tracking emails. Use this skill when users want to send emails, manage domains, routes, templates, mailing lists, or suppressions in Mailgun. For other third party apps, use the api-gateway skill (https://clawhub.ai/byungkyu/api-gateway).
使用说明 (SKILL.md)

Mailgun

Access the Mailgun API with managed OAuth authentication. Send transactional emails, manage domains, routes, templates, mailing lists, suppressions, and webhooks.

Quick Start

# List domains
python \x3C\x3C'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/mailgun/v3/domains')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Base URL

https://gateway.maton.ai/mailgun/v3/{resource}

Replace {resource} with the actual Mailgun API endpoint path. The gateway proxies requests to api.mailgun.net/v3 (US region) and automatically injects your OAuth token.

Regional Note: Mailgun has US and EU regions. The gateway defaults to US region (api.mailgun.net).

Authentication

All requests require the Maton API key in the Authorization header:

Authorization: Bearer $MATON_API_KEY

Environment Variable: Set your API key as MATON_API_KEY:

export MATON_API_KEY="YOUR_API_KEY"

Getting Your API Key

  1. Sign in or create an account at maton.ai
  2. Go to maton.ai/settings
  3. Copy your API key

Connection Management

Manage your Mailgun OAuth connections at https://ctrl.maton.ai.

List Connections

python \x3C\x3C'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections?app=mailgun&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Create Connection

python \x3C\x3C'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'mailgun'}).encode()
req = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Get Connection

python \x3C\x3C'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Response:

{
  "connection": {
    "connection_id": "78b5a036-c621-40c2-b74b-276195735af2",
    "status": "ACTIVE",
    "creation_time": "2026-02-12T02:24:16.551210Z",
    "last_updated_time": "2026-02-12T02:25:03.542838Z",
    "url": "https://connect.maton.ai/?session_token=...",
    "app": "mailgun",
    "metadata": {}
  }
}

Open the returned url in a browser to complete OAuth authorization.

Delete Connection

python \x3C\x3C'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}', method='DELETE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Specifying Connection

If you have multiple Mailgun connections, specify which one to use with the Maton-Connection header:

python \x3C\x3C'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/mailgun/v3/domains')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Maton-Connection', '78b5a036-c621-40c2-b74b-276195735af2')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

If omitted, the gateway uses the default (oldest) active connection.

API Reference

Important: Mailgun API uses application/x-www-form-urlencoded for POST/PUT requests, not JSON.

Domains

List Domains

GET /mailgun/v3/domains

Returns all domains for the account.

Get Domain

GET /mailgun/v3/domains/{domain_name}

Create Domain

POST /mailgun/v3/domains
Content-Type: application/x-www-form-urlencoded

name=example.com&smtp_password=supersecret

Delete Domain

DELETE /mailgun/v3/domains/{domain_name}

Messages

Send Message

POST /mailgun/v3/{domain_name}/messages
Content-Type: application/x-www-form-urlencoded

[email protected]&[email protected]&subject=Hello&text=Hello World

Parameters:

  • from (required) - Sender email address
  • to (required) - Recipient(s), comma-separated
  • cc - CC recipients
  • bcc - BCC recipients
  • subject (required) - Email subject
  • text - Plain text body
  • html - HTML body
  • template - Name of stored template to use
  • o:tag - Tag for tracking
  • o:tracking - Enable/disable tracking (yes/no)
  • o:tracking-clicks - Enable click tracking
  • o:tracking-opens - Enable open tracking
  • h:X-Custom-Header - Custom headers (prefix with h:)
  • v:custom-var - Custom variables for templates (prefix with v:)

Send MIME Message

POST /mailgun/v3/{domain_name}/messages.mime
Content-Type: multipart/form-data

[email protected]&message=\x3CMIME content>

Events

List Events

GET /mailgun/v3/{domain_name}/events

Query parameters:

  • begin - Start time (RFC 2822 or Unix timestamp)
  • end - End time
  • ascending - Sort order (yes/no)
  • limit - Results per page (max 300)
  • event - Filter by event type (accepted, delivered, failed, opened, clicked, unsubscribed, complained, stored)
  • from - Filter by sender
  • to - Filter by recipient
  • tags - Filter by tags

Routes

Routes are defined globally per account, not per domain.

List Routes

GET /mailgun/v3/routes

Query parameters:

  • skip - Number of records to skip
  • limit - Number of records to return

Create Route

POST /mailgun/v3/routes
Content-Type: application/x-www-form-urlencoded

priority=0&description=My Route&expression=match_recipient(".*@example.com")&action=forward("https://example.com/webhook")

Parameters:

  • priority - Route priority (lower = higher priority)
  • description - Route description
  • expression - Filter expression (match_recipient, match_header, catch_all)
  • action - Action(s) to take (forward, store, stop)

Get Route

GET /mailgun/v3/routes/{route_id}

Update Route

PUT /mailgun/v3/routes/{route_id}
Content-Type: application/x-www-form-urlencoded

priority=1&description=Updated Route

Delete Route

DELETE /mailgun/v3/routes/{route_id}

Webhooks

List Webhooks

GET /mailgun/v3/domains/{domain_name}/webhooks

Create Webhook

POST /mailgun/v3/domains/{domain_name}/webhooks
Content-Type: application/x-www-form-urlencoded

id=delivered&url=https://example.com/webhook

Webhook types: accepted, delivered, opened, clicked, unsubscribed, complained, permanent_fail, temporary_fail

Get Webhook

GET /mailgun/v3/domains/{domain_name}/webhooks/{webhook_type}

Update Webhook

PUT /mailgun/v3/domains/{domain_name}/webhooks/{webhook_type}
Content-Type: application/x-www-form-urlencoded

url=https://example.com/new-webhook

Delete Webhook

DELETE /mailgun/v3/domains/{domain_name}/webhooks/{webhook_type}

Templates

List Templates

GET /mailgun/v3/{domain_name}/templates

Create Template

POST /mailgun/v3/{domain_name}/templates
Content-Type: application/x-www-form-urlencoded

name=my-template&description=Welcome email&template=\x3Chtml>\x3Cbody>Hello {{name}}\x3C/body>\x3C/html>

Get Template

GET /mailgun/v3/{domain_name}/templates/{template_name}

Delete Template

DELETE /mailgun/v3/{domain_name}/templates/{template_name}

Mailing Lists

List Mailing Lists

GET /mailgun/v3/lists/pages

Create Mailing List

POST /mailgun/v3/lists
Content-Type: application/x-www-form-urlencoded

[email protected]&name=Newsletter&description=Monthly newsletter&access_level=readonly

Access levels: readonly, members, everyone

Get Mailing List

GET /mailgun/v3/lists/{list_address}

Update Mailing List

PUT /mailgun/v3/lists/{list_address}
Content-Type: application/x-www-form-urlencoded

name=Updated Newsletter

Delete Mailing List

DELETE /mailgun/v3/lists/{list_address}

Mailing List Members

List Members

GET /mailgun/v3/lists/{list_address}/members/pages

Add Member

POST /mailgun/v3/lists/{list_address}/members
Content-Type: application/x-www-form-urlencoded

[email protected]&name=John Doe&subscribed=yes

Get Member

GET /mailgun/v3/lists/{list_address}/members/{member_address}

Update Member

PUT /mailgun/v3/lists/{list_address}/members/{member_address}
Content-Type: application/x-www-form-urlencoded

name=Jane Doe&subscribed=no

Delete Member

DELETE /mailgun/v3/lists/{list_address}/members/{member_address}

Suppressions

Bounces

# List bounces
GET /mailgun/v3/{domain_name}/bounces

# Add bounce
POST /mailgun/v3/{domain_name}/bounces
Content-Type: application/x-www-form-urlencoded

[email protected]&code=550&error=Mailbox not found

# Get bounce
GET /mailgun/v3/{domain_name}/bounces/{address}

# Delete bounce
DELETE /mailgun/v3/{domain_name}/bounces/{address}

Unsubscribes

# List unsubscribes
GET /mailgun/v3/{domain_name}/unsubscribes

# Add unsubscribe
POST /mailgun/v3/{domain_name}/unsubscribes
Content-Type: application/x-www-form-urlencoded

[email protected]&tag=*

# Delete unsubscribe
DELETE /mailgun/v3/{domain_name}/unsubscribes/{address}

Complaints

# List complaints
GET /mailgun/v3/{domain_name}/complaints

# Add complaint
POST /mailgun/v3/{domain_name}/complaints
Content-Type: application/x-www-form-urlencoded

[email protected]

# Delete complaint
DELETE /mailgun/v3/{domain_name}/complaints/{address}

Whitelists

# List whitelists
GET /mailgun/v3/{domain_name}/whitelists

# Add to whitelist
POST /mailgun/v3/{domain_name}/whitelists
Content-Type: application/x-www-form-urlencoded

[email protected]

# Delete from whitelist
DELETE /mailgun/v3/{domain_name}/whitelists/{address}

Statistics

Get Stats

GET /mailgun/v3/{domain_name}/stats/total?event=delivered&event=opened

Query parameters:

  • event (required) - Event type(s): accepted, delivered, failed, opened, clicked, unsubscribed, complained
  • start - Start date (RFC 2822 or Unix timestamp)
  • end - End date
  • resolution - Data resolution (hour, day, month)
  • duration - Period to show stats for

Tags

List Tags

GET /mailgun/v3/{domain_name}/tags

Get Tag

GET /mailgun/v3/{domain_name}/tags/{tag_name}

Delete Tag

DELETE /mailgun/v3/{domain_name}/tags/{tag_name}

IPs

List IPs

GET /mailgun/v3/ips

Get IP

GET /mailgun/v3/ips/{ip_address}

Domain Tracking

Get Tracking Settings

GET /mailgun/v3/domains/{domain_name}/tracking

Update Open Tracking

PUT /mailgun/v3/domains/{domain_name}/tracking/open
Content-Type: application/x-www-form-urlencoded

active=yes

Update Click Tracking

PUT /mailgun/v3/domains/{domain_name}/tracking/click
Content-Type: application/x-www-form-urlencoded

active=yes

Update Unsubscribe Tracking

PUT /mailgun/v3/domains/{domain_name}/tracking/unsubscribe
Content-Type: application/x-www-form-urlencoded

active=yes&html_footer=\x3Ca href="%unsubscribe_url%">Unsubscribe\x3C/a>

Credentials

List Credentials

GET /mailgun/v3/domains/{domain_name}/credentials

Create Credential

POST /mailgun/v3/domains/{domain_name}/credentials
Content-Type: application/x-www-form-urlencoded

login=alice&password=supersecret

Delete Credential

DELETE /mailgun/v3/domains/{domain_name}/credentials/{login}

Pagination

Mailgun uses cursor-based pagination:

{
  "items": [...],
  "paging": {
    "first": "https://api.mailgun.net/v3/.../pages?page=first&limit=100",
    "last": "https://api.mailgun.net/v3/.../pages?page=last&limit=100",
    "next": "https://api.mailgun.net/v3/.../pages?page=next&limit=100",
    "previous": "https://api.mailgun.net/v3/.../pages?page=prev&limit=100"
  }
}

Use limit parameter to control page size (default: 100).

Code Examples

JavaScript - Send Email

const formData = new URLSearchParams();
formData.append('from', '[email protected]');
formData.append('to', '[email protected]');
formData.append('subject', 'Hello');
formData.append('text', 'Hello World!');

const response = await fetch(
  'https://gateway.maton.ai/mailgun/v3/example.com/messages',
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.MATON_API_KEY}`,
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: formData.toString()
  }
);
const result = await response.json();
console.log(result);

Python - Send Email

import os
import requests

response = requests.post(
    'https://gateway.maton.ai/mailgun/v3/example.com/messages',
    headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'},
    data={
        'from': '[email protected]',
        'to': '[email protected]',
        'subject': 'Hello',
        'text': 'Hello World!'
    }
)
print(response.json())

Python - List Domains

import os
import requests

response = requests.get(
    'https://gateway.maton.ai/mailgun/v3/domains',
    headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'}
)
domains = response.json()
for domain in domains['items']:
    print(f"{domain['name']}: {domain['state']}")

Python - Create Route and Webhook

import os
import requests

headers = {'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'}
domain = 'example.com'

# Create route
route_response = requests.post(
    'https://gateway.maton.ai/mailgun/v3/routes',
    headers=headers,
    data={
        'priority': 0,
        'description': 'Forward to webhook',
        'expression': 'match_recipient("[email protected]")',
        'action': 'forward("https://myapp.com/incoming-email")'
    }
)
print(f"Route created: {route_response.json()}")

# Create webhook
webhook_response = requests.post(
    f'https://gateway.maton.ai/mailgun/v3/domains/{domain}/webhooks',
    headers=headers,
    data={
        'id': 'delivered',
        'url': 'https://myapp.com/webhook/delivered'
    }
)
print(f"Webhook created: {webhook_response.json()}")

Notes

  • Mailgun uses application/x-www-form-urlencoded for POST/PUT requests, not JSON
  • Domain names must be included in most endpoint paths
  • Routes are global (per account), not per domain
  • Sandbox domains require authorized recipients for sending
  • Dates are returned in RFC 2822 format
  • Event logs are stored for at least 3 days
  • Stats require at least one event parameter
  • Templates use Handlebars syntax by default
  • IMPORTANT: When using curl commands, use curl -g when URLs contain brackets to disable glob parsing
  • IMPORTANT: When piping curl output to jq, environment variables may not expand correctly. Use Python examples instead.

Rate Limits

Operation Limit
Sending Varies by plan
API calls No hard limit, but excessive requests may be throttled

When rate limited, implement exponential backoff for retries.

Error Handling

Status Meaning
400 Bad request or missing Mailgun connection
401 Invalid or missing Maton API key
403 Forbidden (e.g., sandbox domain restrictions)
404 Resource not found
429 Rate limited
4xx/5xx Passthrough error from Mailgun API

Troubleshooting: API Key Issues

  1. Check that the MATON_API_KEY environment variable is set:
echo $MATON_API_KEY
  1. Verify the API key is valid by listing connections:
python \x3C\x3C'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

Troubleshooting: Invalid App Name

  1. Ensure your URL path starts with mailgun. For example:
  • Correct: https://gateway.maton.ai/mailgun/v3/domains
  • Incorrect: https://gateway.maton.ai/v3/domains

Troubleshooting: Sandbox Domain Restrictions

Sandbox domains can only send to authorized recipients. To send emails:

  1. Upgrade to a paid plan, or
  2. Add recipient addresses to authorized recipients in the Mailgun dashboard

Resources

安全使用建议
This skill proxies Mailgun through Maton and requires a MATON_API_KEY. Before installing or enabling it: 1) Confirm you trust maton.ai/maton services (they will see and act on Mailgun data and OAuth). 2) Use least-privilege credentials or a dedicated Maton API key tied to a non-production Mailgun account if possible. 3) Review Maton's privacy/security docs and the ctrl.maton.ai/gateway.maton.ai URLs referenced in the instructions. 4) Remember the agent can invoke the skill autonomously — it could send API requests (including sending mail) using your key without an extra prompt. 5) Rotate or revoke the key if you stop using the skill or suspect misuse.
功能分析
Type: OpenClaw Skill Name: mailgun-api Version: 1.0.0 The skill bundle provides a legitimate integration for the Mailgun API via the Maton AI gateway. All code examples and instructions in SKILL.md consistently direct network requests to `gateway.maton.ai`, `ctrl.maton.ai`, or `connect.maton.ai`, which are associated with the Maton service. The `MATON_API_KEY` is accessed from environment variables and used for authentication, which is expected for an API skill. There is no evidence of data exfiltration to unauthorized third parties, persistence mechanisms, obfuscation, or malicious prompt injection attempts against the AI agent. The content is aligned with its stated purpose of managing Mailgun resources.
能力评估
Purpose & Capability
The skill advertises Mailgun integration but consistently instructs clients to use Maton endpoints (gateway.maton.ai and ctrl.maton.ai) and requires only MATON_API_KEY. Requiring a Maton API key is coherent with a managed-OAuth gateway approach.
Instruction Scope
Runtime instructions are limited to HTTP calls to Maton gateway/control endpoints and use only the declared MATON_API_KEY. They do not instruct reading unrelated files or other environment variables. Note: the gateway/proxy endpoints are operated by Maton (not api.mailgun.net directly), so you are delegating Mailgun OAuth flows and API calls to that third party.
Install Mechanism
Instruction-only skill with no install spec and no code files to execute on install; this is the lowest-risk installation model.
Credentials
Only MATON_API_KEY is required, which is proportional to a managed gateway design. However, that single key grants Maton-level access which can act on behalf of your Mailgun account via the gateway, so trust in the Maton service and key scope matters.
Persistence & Privilege
The skill is not always-enabled and does not request system-wide persistence. disable-model-invocation is false (normal), meaning the agent can call the skill autonomously — expected for skills but consider runtime behavior with any credential you provide.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install mailgun-api
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /mailgun-api 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of Mailgun API integration with managed OAuth. - Provides access to Mailgun API for sending, receiving, and tracking emails via the Maton gateway. - Includes detailed setup instructions for quick start, base URLs, and authentication using the MATON_API_KEY. - Supports connection management for multiple Mailgun accounts with examples for listing, creating, getting, and deleting connections. - Documents domain, message, events, routes, webhook, and template management endpoints. - Offers guidance on region selection and necessary request formats (form vs. JSON). - Clarifies differences from the generic api-gateway skill and links to relevant resources.
元数据
Slug mailgun-api
版本 1.0.0
许可证
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Mailgun 是什么?

Mailgun API integration with managed OAuth. Transactional email service for sending, receiving, and tracking emails. Use this skill when users want to send emails, manage domains, routes, templates, mailing lists, or suppressions in Mailgun. For other third party apps, use the api-gateway skill (https://clawhub.ai/byungkyu/api-gateway). 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 766 次。

如何安装 Mailgun?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install mailgun-api」即可一键安装,无需额外配置。

Mailgun 是免费的吗?

是的,Mailgun 完全免费(开源免费),可自由下载、安装和使用。

Mailgun 支持哪些平台?

Mailgun 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Mailgun?

由 byungkyu(@byungkyu)开发并维护,当前版本 v1.0.0。

💬 留言讨论